2021-08-08 WPF控件专题 Calendar 控件详解
【摘要】
1.Calendar 控件介绍
可视化的日历控件 月历显示来选择日期
2.具体案例
<Grid>
<!--DisplayMode 默认Month SelectionMo...
1.Calendar 控件介绍
可视化的日历控件 月历显示来选择日期
2.具体案例
<Grid>
<!--DisplayMode 默认Month SelectionMode 默认SingleDate-->
<Calendar Name="calDate" HorizontalAlignment="Left" Margin="117,124,0,0" VerticalAlignment="Top" Height="166" Width="190" DisplayMode="Month" DisplayDateStart="2020-5-1" DisplayDateEnd="2020-6-10" IsTodayHighlighted="True" SelectionMode="MultipleRange" IsTabStop="False" PreviewMouseUp="CalDate_PreviewMouseUp" />
<TextBox Name="txtStart" HorizontalAlignment="Left" Height="23" Margin="176,65,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<TextBox Name="txtEnd" HorizontalAlignment="Left" Height="23" Margin="340,65,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<TextBox Name="txtSel" HorizontalAlignment="Left" Height="23" Margin="24,65,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<Button Content="Button" HorizontalAlignment="Left" Margin="349,155,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
</Grid>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
private void Calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
{
txtStart.Text = calDate.SelectedDates.First().ToShortDateString();
txtEnd.Text = calDate.SelectedDates.Last().ToShortDateString();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
txtSel.Text = calDate.SelectedDate.Value.ToShortDateString();
}
private void CalDate_PreviewMouseUp(object sender, MouseButtonEventArgs e)
{
if (Mouse.Captured is CalendarItem)
{
Mouse.Capture(null);
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
文章来源: codeboy.blog.csdn.net,作者:愚公搬代码,版权归原作者所有,如需转载,请联系作者。
原文链接:codeboy.blog.csdn.net/article/details/119522675
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)