只有WPF工具包DatePicker的月/年 [英] WPF Toolkit DatePicker Month/Year Only

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

问题描述

我使用的工具包的日期选择器上面一样,但我想它限制为仅月份和年份的选择,因为在这种情况下,用户不知道或关心的确切日期。显然与存储数据datetime格式会有一天储存但这并不关心我。有没有一种简单的方法,以配合下来?

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?

感谢

推荐答案

如果您可以使用日历控件,而不是你可以做

If you can use the Calendar control instead you could do

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

本codebehind

with this codebehind

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天全站免登陆