我正在开发日历,因为我正在使用wpcontrol日历和(windows phone control)datepicker,以及当我在datepicker中更改日期时如何在日历中设置日期。
xaml代码:
<wpControls:Calendar x:Name="Cal ColorConverter="{StaticResource ColorConverter}"MonthChanged="Cal_MonthChanged" MonthChanging="Cal_MonthChanging" SelectionChanged="Cal_SelectionChanged" DateClicked="Cal_DateClicked"/>
xaml datepicker:
<toolkit:DatePicker x:Name="Datepicker1" ValueChanged="DatePicker_ValueChanged" Margin="16,145,8,-227" Grid.Row="1"/>
c sharp:
我刚试了一个日历的静态新日期。
private void DatePicker_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
{
Cal.SelectedDate = new DateTime(2012, 2, 1);
}
答案 0 :(得分:1)
试试这个:
XAML:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<toolkit:DatePicker x:Name="datePicker" ValueChanged="datePicker_ValueChanged"/>
<wpControls:Calendar x:Name="calender"></wpControls:Calendar>
</StackPanel>
</Grid>
CS:
private void datePicker_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
{
if (datePicker != null)
{
calender.SelectedDate = datePicker.Value.Value.Date;
calender.Refresh();
}
}