I'm trying to get the listpicker to show a property that is in an iList. When i run the app, what comes up instead is the binding info.. not that property..
Here is the xaml
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Name="lpkItemTemplate">
<TextBlock Text="{Binding Operation}" />
</DataTemplate>
<DataTemplate x:Name="lpkFullItemTemplate">
<TextBlock Text="{Binding Operation}" />
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<toolkit:ListPicker x:Name="lbOperation" Header="Operations" SelectedIndex="0"
FullModeItemTemplate="{Binding lpkFullItemTemplate}"
ItemTemplate="{Binding lpkItemTemplate}"
Grid.Row="5"
>
and the code behind
Dim Os As List(Of wsOperation.Operation) = e.Result
Me.lbOperation.ItemsSource = Os
i'm thinking it is a template error because the number of rows in the list is the number that comes up when i click on the listpicker.. but the property i've asked ("Operation") is not displaying the data. Instead i get ~10 rows of wsOperation.Operation showing up.
thanks
shannon
~~~~~~~~~
maybe a little more info will help with a possible solution
Here is what the listpicker shows when i run this page
ProcWP.wsOperation.Operation
when i click on the above line.. this is what the listpicker shows
ProcWP.wsOperation.Operation
ProcWP.wsOperation.Operation
ProcWP.wsOperation.Operation
ProcWP.wsOperation.Operation
ProcWP.wsOperation.Operation
ProcWP.wsOperation.Operation
ProcWP.wsOperation.Operation
ProcWP.wsOperation.Operation
ProcWP.wsOperation.Operation
ProcWP.wsOperation.Operation
ProcWP.wsOperation.Operation
ProcWP.wsOperation.Operation
the answer to this problem was in the toolkit:ListPicker. I needed to change the {Binding lpkFullItemTemplate} to {StaticResource lpkFullItemTemplate} and same with itemTemplate
so it looks like this now
<toolkit:ListPicker x:Name="lbOperation" Header="Operations" SelectedIndex="1"
FullModeItemTemplate="{StaticResource lpkFullItemTemplate}"
ItemTemplate="{StaticResource lpkItemTemplate}"
Grid.Row="5"
>
Related
I add a ComboBox in XAML for Windows Phone 8.1 in a StackPanel. On Running the app in the Emulator no Dropdown functionality is shown. If I Limit the StackPanel to a Height e.g. "70", only the 2 first Items are shown. If I say Height = "Auto" then all Items are shown immediately.
How can I enable the Dropdown functionality?
Header:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Combobox ..
<StackPanel Grid.Row="4" Width="350" HorizontalAlignment="Left">
<TextBlock x:Name="PlayerListPanel" TextWrapping="Wrap" Text="Select a Player" VerticalAlignment="Center" Margin="2,0,0,0" HorizontalAlignment="Left"/>
<ComboBox Name="StartPlayerComboBox" BorderThickness="1" >
<ComboBoxItem Tag="PLAYER1">Player 1</ComboBoxItem>
<ComboBoxItem Tag="PLAYER2">Player 2</ComboBoxItem>
<ComboBoxItem Tag="PLAYER3">Player 3</ComboBoxItem>
<ComboBoxItem Tag="Dummy1">1</ComboBoxItem>
<ComboBoxItem Tag="Dummy2">2</ComboBoxItem>
<ComboBoxItem Tag="Dummy3">3</ComboBoxItem>
</ComboBox>
</StackPanel>
Try LISTPICKER control..Its functions similar as ComboBox with Auto adjusting height and width..
<toolkit:ListPicker>
<toolkit:ListPickerItem Content="A+" />
<toolkit:ListPickerItem Content="B+" />
<toolkit:ListPickerItem Content="O+" />
</toolkit:ListPicker>
to use this Include following namespace in Xaml Page..ADD windows phone toolkit(click it)
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;
assembly=Microsoft.Phone.Controls.Toolkit"
if further info requires... revert back...
You should provide enough height for the combobox to open properly. If you limit the height, the combobox cannot extend beyond that. So it will show only a few items. Height = "Auto" means it can take whatever height as required by it. Thus the combobox will take the height required for it to open properly.
Combobox is Windows Phone/ Windows RunTime Environment behaves differently from its Silverlight/WPF Counterparts. Here we don't have Popup to show the List of items to be selected. Hence the dropdown needs enough space to show the options.
Best thing is to leave the Height as Auto, or MinWidth for any Width requirements.
Even tho, this is an old question, in addition to what they have said, already; a way to have an item selected as the default, you need to "mark it" as follow:
<ComboBoxItem IsSelected="True">Item 1</ComboBoxItem>
Then, once you click on it, you will have all other combo box items displayed (if you define them):
<ComboBox x:Name="myComboBox" VerticalAlignment="Top" Width="350" FontFamily="open sans" FontSize="20" Height="Auto" Foreground="DarkGray" BorderBrush="Black">
<ComboBoxItem IsSelected="True">Item 1</ComboBoxItem>
<ComboBoxItem>Item 2</ComboBoxItem>
<ComboBoxItem>Item 3</ComboBoxItem>
<ComboBoxItem>Item 4</ComboBoxItem>
</ComboBox>
Hope it helps someone. Regards
I put StackPanel into ScrollViewr, When scrolling to last item it returns back to its old position.
<ScrollViewer Margin="0,0,0,20">
<StackPanel>
//Textblocks and Textboxes ...
</StackPanel>
</ScrollViewer>
After search i found that:
ItemsControl, VirtualizingStackPanel and ScrollViewer height
I changed my code to:
<StackPanel>
//Textblocks and Textboxes ...
</StackPanel>
<ScrollViewer>
<VirtualizingStackPanel />
</ScrollViewer>
I can't set CanContentScroll="True" as i can't find it.
Also make exception:
System.InvalidOperationException: A VirtualizingPanel is not nested in an ItemsControl. VirtualizingPanel must be nested in ItemsControl to get and show items.
What must i do, to enable scrolling without returning back to its old position?
Regards,
After search again ...
I found this Post which solve the problem of Scrolling return to old position when open keyboard.
Scrolling page with keyboard shown
code after updates:
<ScrollViewer Height="500" VerticalAlignment="Top">
<StackPanel Height="700">
//Textblocks and Textboxes ...
</StackPanel>
</ScrollViewer>
I have Windows Phone 8 page which has a number of controls on it, some of them are LongListSelector controls. If all collections have content everything is displayed correctly.
But if any of the collections bound to the lists are empty all controls below them on the page disappear, i.e. the page looks to be truncated as lots of things are missing.
If I add code to make sure to add at least on item to each collection the page display correctly.
The databinding is done using C#, as shown below.
XAML
<phone:LongListSelector Grid.Row="3" x:Name="PicturesGrid">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Image Source="{Binding Filename}" />
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
C#
PicturesGrid.ItemsSource = App.ViewModel.SelectedBird.Pictures;
Update: I have noticed that there is a scrollbar present, but however much I scroll I never get down to the bottom.
For a windows 8 Apps, i need to put a list of buttons over an image. Each button has CoordinateX and CoordinateY properties. I use a gridView to bind to the list of buttons.
I need to have the result as below:
Here is my code:
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" >
<Canvas>
<Image Source="ms-appx:///Assets/red.png" Stretch="None" ></Image>
<GridView ItemsSource="{Binding Buttons}"
SelectionMode="None" IsSwipeEnabled="false" IsItemClickEnabled="True" ItemClick="Button" Padding="0">
<GridView.ItemTemplate>
<DataTemplate>
<Button Width="194" Height="51" Background="Gray" Canvas.Left="{Binding CoordinateX}" Canvas.Top="{Binding CoordinateY}"></Button>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Canvas>
</Grid>
But this is what i get after running the app:
Ites Likely that at runtime before the X and Y co-ordinates can be set for the items within the GridView, the GridView itself has its properties applied.
Since
1) the GridView is intended to be used for oganization control
and
2) you havent forced the Grid to fill the view space
what you're left with is a GridView that acts as it wishes and limits the ability of its items to conform to your style, should the style attempt to force the items collection to live outside the bounds of the control.
You could try to set the GridView's Horizontal Alignment property but even if it happens to work, its probably a better bet to use a less organized content control like the more basic ItemsPresenter.
Which ever control you end up using... make sure to check for /set the HorizontalContentAlignment & VerticalContentAlignment properties if they exist.
I am new to the XAML world and I'm fumbling my way through a lot of tutorials. One thing i'm stuck on is calling the .tostring on an object.
Here is mysetup
I have a listbox that is bound to a list of objects
I have a contentControl bound to the same list that displays the selected item from the listbox.
My ContentControl is as follows:
<ContentControl Grid.Row="1" Margin="0,3,5,204" Name="Detail"
Content="{Binding Source={StaticResource listingDataView}}"
ContentTemplate="{StaticResource myContentTemplate}"
HorizontalAlignment="Right" Width="231"/>
in myContentTemplate I have:
<DataTemplate x:Key="myContentTemplate">
<StackPanel>
<TextBlock Text="{Binding Path=Name}" />
<!-- want to call .tostring here-->
</StackPanel>
</DataTemplate>
In the template I'd like to call .tostring on the object that is currently selected but i cant figure out how to do that?
thanks
Steph
well looks like i asked this too soon. I found the answer in another question
How to reference current object in XAML
Quoting the answer from that thread:
According to the Data Binding
Overview, you can use the "/" to
indicate the current item. You can
then navigate up and down the tree as
needs be using the following type
syntaxes:
Button Content="{Binding }" />
Button Content="{Binding Path=/}" />
Button Content="{Binding
Path=/Description}" />
Hope this helps someone else :)