WPF工具包DatePicker更改默认值'显示日历' [英] WPF toolkit DatePicker change default value 'show calendar'

查看:204
本文介绍了WPF工具包DatePicker更改默认值'显示日历'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最新的 WPF工具包,特别是 DatePicker 。一切工作正常,但是当没有提供任何值时,默认的SHOW CALENDAR文本显示在DatePickerTextBox中。
我希望能够在WPF中更改此值。一个人告诉我要下载源码,添加一个新的Dependency属性并重新编译为dll。



这很酷,但如果新版本发布怎么办?



这就是为什么我想以这种方式模板这个控件,我可以覆盖这个默认字符串。任何想法如何做?



谢谢!

解决方案

。我找到了一个解决方案。

 < Style TargetType ={x:Type toolkit:DatePickerTextBox}> 
< Setter Property =TextValue =Bittewählen/>
< / Style>

无论如何,你必须注意事实,那就是一个称为Watermark的DependencyProperty应该被设置为替代Text。



问题是,随着最新的MS版本(大约2009年6月),由于一些未知的原因,他们使这个属性只读。这意味着,这是唯一的黑客,虽然发生了第一次异常,因为DatePicker试图解析字符串(他认为文本是一个Date),但通常你不会注意到。



另一种可能性是直接从MS编辑源代码,覆盖 SetWaterMark()方法+添加您自己的依赖属性(MyWaterMark或某些东西)。但是,您不能使用提供的 dll 。他们表示将会使用.NET 4 realese 修正


I'm using the latest WPF toolkit, specifically the DatePicker. Everything works fine, but when no value is provided, the default 'SHOW CALENDAR' text appears in the DatePickerTextBox. I want to be able to change this value in WPF.

One told me to download the source, add a new Dependency property and recompile to dll. That's cool but what if new version is released?

That's why I'd like to template this control in that way, that I'll be able to override this default string. Any idea how to do that?

Thanks!

解决方案

OK. I found a solution by myself.

<Style TargetType="{x:Type toolkit:DatePickerTextBox}">
    <Setter Property="Text" Value="Bitte wählen" />
</Style>

Anyways, you have to be aware of the fact, that there is a DependencyProperty called Watermark which should be set in place of the Text.

The problem is that with the latest MS release (about June 2009) they made this property readonly for some unknown reason. That means, this is the only hack I made up, although there occurs a First-time exception, because the DatePicker is trying to parse the string (he supposes the text to be a Date), but normally you won't notice it.

Another possibility is to edit directly the source code from MS and override the SetWaterMark() method + add your own Dependency Property (MyWaterMark or something). But then you cannot use the provided dll. They said it will come fixed with the .NET 4 realese, let's see.

这篇关于WPF工具包DatePicker更改默认值'显示日历'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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