【发布时间】:2014-04-25 06:52:34
【问题描述】:
我正在尝试获取当前月份并将其设置为列表选择器中的默认项目。我想怎么做到这一点,因为我不知道我应该怎么做。我试过 selectedindex = indexnumber 但它崩溃了。以下是我的代码:
c#
var month= DateTime.Now.Month;
monthCat.Items.Add("January");
monthCat.Items.Add("February");
monthCat.Items.Add("March");
monthCat.Items.Add("April");
onthCat.Items.Add("May");
monthCat.Items.Add("June");
monthCat.Items.Add("July");
monthCat.Items.Add("August");
onthCat.Items.Add("September");
monthCat.Items.Add("October");
monthCat.Items.Add("November");
monthCat.Items.Add("December");
//ListPicker.SelectedIndex = month;
xaml
<toolkit:ListPicker Name="monthCat" ExpansionMode="FullScreenOnly">
<toolkit:ListPicker.FullModeItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize="40" Margin="10"/>
</DataTemplate>
</toolkit:ListPicker.FullModeItemTemplate>
</toolkit:ListPicker>
【问题讨论】:
标签: c# xaml windows-phone-8 windows-phone listpicker