我從我正在開發的應用程序創建了一個測試應用程序。我有一個listpicker與一組顏色出於某種原因,當它進入全模式選擇沒有被更新。listpicker fullmode沒有更新選項
我已經下載了2個這樣的例子,我沒有看到我錯過了什麼。感謝
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Name="lstColorsItemTemplate">
<StackPanel Orientation="Horizontal">
<Rectangle Fill="{Binding pickedColorBlock}" Height="30" Width="30"/>
<TextBlock Text="{Binding pickedColor}" Foreground="{StaticResource PhoneAccentBrush}" Margin="10,0,0,0" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Name="fulllstColorsItemTemplate" >
<StackPanel Orientation="Horizontal" >
<Rectangle Fill="{Binding pickedColorBlock}" Height="30" Width="30" Margin="0,0,10,10" />
<TextBlock Text="{Binding pickedColor}" Foreground="{StaticResource PhoneAccentBrush}" Margin="10,0,0,0" FontSize="20" />
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<StackPanel Orientation="Horizontal" Margin="13,113,143,0">
<toolkit:ListPicker x:Name="lstColors" Width="225"
ItemTemplate="{StaticResource lstColorsItemTemplate}"
FullModeItemTemplate="{StaticResource fulllstColorsItemTemplate}"
Header="Font Color"
BorderBrush="{StaticResource PhoneAccentBrush}"
Background="#FFF4F4F5"
CacheMode="BitmapCache"/>
</StackPanel>
後面的代碼
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) //without ToDoTableEntries not set as observablcollection throws null error (never counts up)
{
List<colorChoices> source = new List<colorChoices>();
source.Add(new colorChoices() { pickedColorBlock = Colors.Black.ToString(), pickedColor = "Black", pickedSolidColorBrush = new SolidColorBrush(Colors.Black) });
source.Add(new colorChoices() { pickedColorBlock = Colors.White.ToString(), pickedColor = "White", pickedSolidColorBrush = new SolidColorBrush(Colors.White) });
source.Add(new colorChoices() { pickedColorBlock = Colors.Red.ToString(), pickedColor = "Red", pickedSolidColorBrush = new SolidColorBrush(Colors.Red) });
source.Add(new colorChoices() { pickedColorBlock = Colors.Brown.ToString(), pickedColor = "Brown", pickedSolidColorBrush = new SolidColorBrush(Colors.Brown) });
source.Add(new colorChoices() { pickedColorBlock = Colors.Blue.ToString(), pickedColor = "Blue", pickedSolidColorBrush = new SolidColorBrush(Colors.Blue) });
source.Add(new colorChoices() { pickedColorBlock = Colors.Gray.ToString(), pickedColor = "Gray", pickedSolidColorBrush = new SolidColorBrush(Colors.Gray) });
lstColors.ItemsSource = source;
}
class colorChoices
{
public string pickedColorBlock { get; set; }
public string pickedColor {get; set;}
public SolidColorBrush pickedSolidColorBrush {get; set;}
}
你是什麼意思,它沒有得到更新?你的意思是你不知道FullScreenMode中的哪個項目是SelectedItem? – 2014-10-17 00:19:40
對不起,當我點擊我的列表時,它將帶我到全模式屏幕我選擇我的新顏色,它將我返回到我的原始頁面,但SelectedItem不會更改它保持第一個選項。 – branedge 2014-10-17 01:58:41