是否有办法缩短TimePicker的显示时间? 我没有找到任何合适的属性(很难相信,没有这种可能性),也尝试使用数据上下文:
class TimePickerDataSource
{
public List<TimeSpan> Hours { get; set; }
public TimePickerDataSource()
{
Hours = new List<TimeSpan>{new TimeSpan(9,0,0),new TimeSpan(10,0,0)};
}
}
以及稍后的MyPage.xaml.cs:
StartTimePicker.DataContext = new TimePickerDataSource();
但我不知道如何在我的xaml中绑定它(如果可能的话):
<Grid x:Name="My Grid">
<TextBlock HorizontalAlignment="Left" Margin="129,129,0,0" TextWrapping="Wrap" Text="{Binding DisplayedName}" VerticalAlignment="Top" Height="60" Width="163" FontSize="20" />
<TimePicker x:Name="StartTimePicker" HorizontalAlignment="Left" Margin="168,259,0,0" VerticalAlignment="Top" ClockIdentifier="24HourClock">
</TimePicker>
</Grid>
答案 0 :(得分:0)
在C#代码中你可以试试这个。
this.dateTimePicker1.MaxDate = new System.DateTime(2015, 12, 31, 0, 0, 0, 0);
this.dateTimePicker1.MinDate = new System.DateTime(1999, 1, 1, 0, 0, 0, 0);