文本框为空时禁用按钮 [英] Disable a button when a textbox is empty

查看:332
本文介绍了文本框为空时禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过 禁用按钮的正确方法是什么?当文本字段在用户控件中并且按钮在主窗口中时,使用WPF的ICommand接口?窗口命令和文本框绑定应该绑定在ViewModel中。

What is the proper way to disable a button via  the ICommand interface using WPF when the textfield is in a User Control and the button is in the main window? The window command and the textbox binding should be bound in the ViewModel.

你能给我一个示例代码吗?

Can you give me an example code for that?

推荐答案


您好,

Hi,

通过 禁用按钮的正确方法是什么?当文本字段在用户控件中并且按钮在主窗口中时,使用WPF的ICommand接口?窗口命令和文本框绑定应该绑定在ViewModel中。

What is the proper way to disable a button via  the ICommand interface using WPF when the textfield is in a User Control and the button is in the main window? The window command and the textbox binding should be bound in the ViewModel.

你能给我一个示例代码吗?

Can you give me an example code for that?

Hi FeyPeshev,

Hi FeyPeshev,

根据您的描述,主窗口和UserControl称为Usercontrol1。 Usercontrol1中的TextBox,主窗口中的Button和UserControl1,现在你想在主窗口的UserControl中TextBox.text为空时禁用Button吗?

According to your description, there are main Window and UserControl called Usercontrol1. A TextBox in Usercontrol1, a Button and UserControl1 in main Window, now you want to disable Button when TextBox.text is empty in UserControl from main Window?

我不确定你想要什么你能在这里描述更详细的信息。

I am not sure what you want to do, can you describe more detailed info here.

最好的问候,

Cherry


这篇关于文本框为空时禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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