I have List of Categories that I want to display in a ListPicker. The Class is:
public class Category : INotifyPropertyChanged, INotifyPropertyChanging
{
private int _id;
public int Id
{
get { return _id; }
set
{
if (_id == value) return;
NotifyPropertyChanging();
_id = value;
NotifyPropertyChanged();
}
}
private string _description;
public string Description
{
get { return _description; }
set
{
if (_description == value) return;
NotifyPropertyChanging();
_description = value;
NotifyPropertyChanged();
}
}
#region INotifyPropertyChanging and INotifyPropertyChanged Members
public event PropertyChangingEventHandler PropertyChanging;
private void NotifyPropertyChanging([CallerMemberName] string propertyName = null)
{
if (PropertyChanging != null) PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
{
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
I have a ListPicker Full Mode Item Template defined as a XAML Resource:
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="FullModeItemTemplate">
<TextBlock d:DataContext="{Binding}"
Text="{Binding Description}"
/>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
and a ListPicker for it defined in XAML on the Page:
<phone:PhoneApplicationPage
x:Class="QuestionPage"
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"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeMedium}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed.-->
<Grid x:Name="LayoutRoot" removed="Transparent">
<Border Style="{StaticResource ButtonBorderStyle}"
removed="Blue"
BorderBrush="White"
>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the app and page title.-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="0,10,0,0">
<TextBlock x:Name="ApplicationTitle"
Text="pagetitle"
Style="{StaticResource PhoneTextLargeStyle}"/>
<TextBlock x:Name="PageTitle"
Text="subtitle"
Style="{StaticResource PhoneTextExtraLargeStyle}"/>
</StackPanel>
<StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="0,0,0,15">
<TextBlock Text="question" Margin="20,5,0,0"/>
<TextBox x:Name="ItemDescription"/>
<TextBlock Text="category" Margin="20,0,0,-10"/>
<toolkit:ListPicker x:Name="CategoriesListPicker"
DataContext="{Binding}" ItemsSource="{Binding Categories}"
DisplayMemberPath="Description"
FullModeHeader="Categories:"
FullModeItemTemplate="{StaticResource FullModeItemTemplate}"
CacheMode="BitmapCache"
>
</toolkit:ListPicker>
</StackPanel>
</Grid>
</Border>
</Grid>
</phone:PhoneApplicationPage>
The ItemDescription and Category are to be saved to a Question Class Item in another list... but this is not relevant to the problem...
If the Category List has five or less items in it, the selection list is displayed in short mode and items from the list can be selected and this selection is reflected in the control field. This is fine.
If I increase the Categories List to over five items, the ListPicker switches to full mode, and although the display of these is fine, when an item from the list is selected, the item shown in the control field remains unchanged.
Is this a bug in the Full Mode selection list or am I missing something?
Any help you can give will be appreciated...