修复DatePicker的样式 [英] Fix DatePicker's style

查看:68
本文介绍了修复DatePicker的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DatePicker是WPF控件的一个糟糕示例.它具有非标准的边框,间距与TextBox不同,它具有附加的内部边框,具有非标准的悬停效果,并且图标与Windows 7中的新图标不同.

DatePicker is an awful example of a WPF control. It has a non-standard border, the spacings are different to a TextBox, it has an additional inner border with a non-standard hover effect, and a different icon than what seems to be new in Windows 7.

DatePicker的Windows窗体版本的行为与其他平台控件非常相似.

The Windows Forms version of a DatePicker behaves much more like any other platform control.

那么我该怎么做才能将WPF DatePicker集成到其环境中?有人为此修复样式吗?最好能无缝地适用于XP/7/8主题的东西.

So what can I do to make WPF DatePicker integrate in its environment? Does somebody have a style fix for it? Preferably something that works in XP/7/8 themes seamlessly.

如果文本输入区像在WinForms中那样被屏蔽,并且将支持向上/向下箭头键来操纵日期的每个部分,那也很好.

It would also be nice if the text input area was masked like in WinForms and would support the up/down arrow keys for manipulating each part of the date.

推荐答案

您可以在Visual Studio 2012或2013中在设计模式下右键单击DatePicker控件,然后选择编辑模板"选项,然后选择编辑副本...",从而自己重新设置样式.选项.这将弹出一个对话框,让您指定名称和 单击对话框中的确定"按钮时为您创建的样式资源的位置.生成的资源将包含DatePicker的默认控件模板,您可以根据需要对其进行修改.

You could re-style it yourself by right-clicking on the DatePicker control in design mode in Visual Studio 2012 or 2013 and select the "Edit template" option and then the "Edit a copy…" option. This will bring up a dialog that lets you specify the name and location of a style resource that is created for you when you click the "OK" button in the dialog. The generated resource will contain the default control template for the DatePicker that you could then modify according to your requirements.

另一个选择是使用某些第三方控件. Extended WPF Toolkit带有DateTimePicker,用户可以使用按钮微调器增加或减少DateTime: https://wpftoolkit.codeplex.com/wikipage?title=DateTimePicker

The other option is to use some third-party control. The Extended WPF Toolkit comes with a DateTimePicker where the user can increment or decrement the DateTime using button spinners: https://wpftoolkit.codeplex.com/wikipage?title=DateTimePicker

DevExpress还提供了一个自定义的DatePicker控件: https://www.devexpress.com/Products/NET/Controls/WPF/Editors/date-picker.xml

DevExpress also provides a custom DatePicker control: https://www.devexpress.com/Products/NET/Controls/WPF/Editors/date-picker.xml


这篇关于修复DatePicker的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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