如何使 WPFToolkit DatePicker 仅突出显示所选日期?
我正在使用 WPFToolkit 中的 DatePicker,但由于当前日期和该月的最后/第一天也突出显示,实际选择的日期令人困惑。
如何才能使日历中除了所选日期之外不突出显示任何内容?
I am using the DatePicker from WPFToolkit, but since the current date and the last/first day of the month is highlighted as well, it is confusing which date is actually selected.
How can I make it so nothing is highlighted in the calendar except the selected date?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解你的问题,你会想要执行以下操作:
1.隐藏当前日期选择
2.当日历控件弹出时,使焦点矩形设置在选定的日期上(或者我想摆脱它)
N1很容易;你应该将 DatePicker 的 IsTodayHighlighted 属性设置为 false,它就会消失
N2 有点棘手。可能有一种更简单的方法来解决这个问题,但这对我有用:DatePicker 在显示日历控件后立即将焦点移动到日历控件,通过调用
此方法使焦点矩形在该月的第一天显示;您可以通过强制日历将焦点移至所选日期来修复此问题;下面是 DatePicker 控件的 CalendarOpened 事件处理程序(在我的例子中为 datePicker1)。我使用反射来访问 datapicker 控件的私有字段 _calendar 并执行其私有方法 FocusDate
这将使日历控件在弹出时看起来更干净;但如果用户开始选择不同的月份,仍然会在该月的第一天显示焦点矩形
希望这有帮助,
问候
if I understood your question correctly you would like to do following:
1. hide the current date selection
2. make focus rectangle to be set on the selected date when calendar control pops up (or I guess get rid of it)
N1 is easy; you should set IsTodayHighlighted property of the DatePicker to false and it would disappear
N2 is a little trickier. There might be an easier way for fixing this but here's what working for me: DatePicker moves focus to the calendar control right after showing it by calling
this makes focus rectangle to be shown on the first day of the month; you can fix it by forcing calendar to move focus to the selected date; below is an CalendarOpened event handler for the DatePicker control (datePicker1 in my case). I'm using reflection to access private field _calendar of the datapicker control and execute its private method FocusDate
this would make calendar control look cleaner when it pops up; but would still show focus rectangle on the first day of the month if user would start selecting different months
hope this helps,
regards