我正在尝试允许listpicker下拉菜单进入全屏模式。当我进入全屏模式时,它只会在第一次机会出现时崩溃。以下是我的代码:
C#:
monthCat.SetValue(Microsoft.Phone.Controls.ListPicker.ItemCountThresholdProperty,12);
XAML:
<toolkit:ListPicker Name="monthCat" ExpansionMode="FullScreenOnly">
<toolkit:ListPickerItem Content="January" />
<toolkit:ListPickerItem Content="February" />
<toolkit:ListPickerItem Content="March" />
<toolkit:ListPickerItem Content="April" />
<toolkit:ListPickerItem Content="May" />
<toolkit:ListPickerItem Content="June" />
<toolkit:ListPickerItem Content="July" />
<toolkit:ListPickerItem Content="August" />
<toolkit:ListPickerItem Content="September" />
<toolkit:ListPickerItem Content="October" />
<toolkit:ListPickerItem Content="November" />
<toolkit:ListPickerItem Content="December" />
</toolkit:ListPicker>
当我删除ExpensionMode时,它工作正常,但它不在全屏模式下。
答案 0 :(得分:3)
试试这个:
public MainPage()
{
InitializeComponent();
SetBinding();
}
void SetBinding()
{
List<string> list = new List<string>();
list.Add("January");
list.Add("February");
list.Add("March");
list.Add("April");
list.Add("May");
list.Add("June");
list.Add("July");
list.Add("August");
list.Add("September");
list.Add("October");
list.Add("November");
list.Add("December");
monthCat.ItemsSource = list;
}
并将此代码粘贴到.xaml文件中。
<toolkit:ListPicker Name="monthCat" ExpansionMode="FullScreenOnly" >
<toolkit:ListPicker.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</toolkit:ListPicker.ItemTemplate>
<toolkit:ListPicker.FullModeItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize="25"/>
</DataTemplate>
</toolkit:ListPicker.FullModeItemTemplate>
</toolkit:ListPicker>