RadDatePicker 输入事件

发布于 2024-10-03 01:10:27 字数 459 浏览 1 评论 0原文

我正在寻找在 RadDatePicker (一个 Telerik 控件)中输入文本时在控件上触发的某种事件。

每次击键时都必须触发它。

我尝试捕获 keyup 事件,该事件工作正常,但是...如果我在字段中输入了类似 1/1/201(这是一个不完整的日期)的内容,则 SelectedValueProperty 不会设置为我输入的不完整日期。

那么我为什么想要那个呢?我应该解释一下。当我发现字段中的某些内容发生更改时,我想要更新日期绑定到的字段(例如在 WPF 中使用 UpdateSourceTrigger.PropertyChanged)。

该字段(以及其他字段)中的内容将决定页面上的另一个按钮是否处于活动状态。

我猜测该解决方案与普通的 DatePicker 相同,因为它归结为 RadDatePicker 有一个内部 TextBlock,可以在其中输入/编辑日期。

谢谢,

彼得。

I was looking for some kind of event that is fired on a RadDatePicker (a telerik control) when text is typed into the control.

It must be fired on every key stroke.

I tried to grab the keyup event, which works fine, but ... if I have typed into the field something like 1/1/201 (which is an incomplete date) the SelectedValueProperty is not set to the incomplete date that I have typed.

So why do I want that? I should explain. When I find that something in the field is changed I want to update the field that the date is bound to (like using UpdateSourceTrigger.PropertyChanged in WPF).

What is in that field (and other fields) will determine whether another button on the page is active or not.

I am guessing that the solution would be the same as a normal DatePicker because what it comes down to is that a RadDatePicker has an internal TextBlock where the date is typed / edited.

Thanks,

Peter.

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

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

发布评论

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

评论(2

后来的我们 2024-10-10 01:10:27

我找到了这个问题的答案,效果非常好。

RadDatePicker 控件上有一个名为 CurrentDateTimeText 的属性。我绑定到此,不是为了获取日期(我还绑定到 SelectedValue 来获取日期),而是为了让我可以判断用户是否在字段中输入了任何内容。

I found an answer for this question that works quite nicely.

On the RadDatePicker control there is a property called CurrentDateTimeText. I am binding to that, not to get the date (I am also binding to the SelectedValue to get the date) but just so that I can tell if the user has entered anything into the field or not.

烟若柳尘 2024-10-10 01:10:27

您可以使用 jQuery 轻松做到这一点:

         $('#yourTelerikControl').keypress(function() {
                    alert('Handler for .keypress() called.');
                 });

You can easily do it with jQuery:

         $('#yourTelerikControl').keypress(function() {
                    alert('Handler for .keypress() called.');
                 });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文