WPF Datepicker 控件无选项(WPF ToolKit)

发布于 2024-08-18 08:10:41 字数 62 浏览 2 评论 0原文

如何在日期选择器控件中提供选择无日期(无)的选项?

请帮忙!!

谢谢 萨拉特

How to provide an option to select No dates(None) in datepicker control?

Please help!!

Thanks
Sharath

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蛮可爱 2024-08-25 08:10:41

现在,我已经实际安装了WPF工具包并尝试了...

我发现,如果您手动删除日期选择器的文本框部分中的文本,则实际上会删除SelectedDate。或者,您可以添加一个直接删除 SelectedDate 的按钮。

WPF 代码:

    <my:DatePicker Name="DatePicker1" Height="26"  xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" />
    <Button Name="btnDeleteDate" Height="26"  Width="90">Set no date</Button>

代码隐藏 (VB):

Private Sub btnDeleteDate_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnDeleteDate.Click
    DatePicker1.SelectedDate = Nothing
End Sub

如果您希望今天的日期不突出显示为灰色,可以将 IsTodayHighlighted 设置为 false。

但它仍然是“活动日期”,它是日期周围的一个可见框,有点像“光标”,如果您使用键盘上的箭头四处移动,它就是起点。这与 SelectedDate 不同,但当您开始移动所选日期时,会立即设置它。

Now, I have actually installed the WPF Toolkit and tried it...

I found out that if you manually delete the text in the textbox part of the datepicker, then the SelectedDate is actually deleted. Optionally, you can add a button that deletes the SelectedDate directly.

WPF code:

    <my:DatePicker Name="DatePicker1" Height="26"  xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" />
    <Button Name="btnDeleteDate" Height="26"  Width="90">Set no date</Button>

Code behind (VB):

Private Sub btnDeleteDate_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnDeleteDate.Click
    DatePicker1.SelectedDate = Nothing
End Sub

If you want the todays date not to be highlighted as grey, you can set IsTodayHighlighted to false.

It is still the "active date" though, which is a visible box around a date that is kind of a "cursor" that is the start point if you move around with the arrows on the keybord. This is not the same as SelectedDate, but the selected date is set immediately when you start to move it around.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文