WPF 工具包 DatePicker 仅限月/年 [英] WPF Toolkit DatePicker Month/Year Only

查看:25
本文介绍了WPF 工具包 DatePicker 仅限月/年的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Toolkit 的 Datepicker 如上所述,但我想将其限制为仅选择月份和年份,因为在这种情况下,用户不知道或不关心确切的日期.显然是存储数据以日期时间格式存储日期,但这与我无关.有没有简单的方法来解决这个问题?

I'm using the Toolkit's Datepicker as above but I'd like to restrict it to month and year selections only, as in this situation the users don't know or care about the exact date .Obviously with the data being stored in a Datetime format there will be day stored but that doesn't concern me. Is there an easy way to tie this down?

谢谢

推荐答案

如果您可以改用 Calendar 控件,您可以这样做

If you can use the Calendar control instead you could do

<toolkit:Calendar x:Name="_calendar" DisplayModeChanged="_calendar_DisplayModeChanged" DisplayMode="Year" />

使用此代码隐藏

Private Sub _calendar_DisplayModeChanged(ByVal sender As System.Object, ByVal e As Microsoft.Windows.Controls.CalendarModeChangedEventArgs)

    If _calendar.DisplayMode = Microsoft.Windows.Controls.CalendarMode.Month Then
        _calendar.DisplayMode = Microsoft.Windows.Controls.CalendarMode.Year
    End If

End Sub

这篇关于WPF 工具包 DatePicker 仅限月/年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆