在文本框的LostFocus事件上如何更改该文本框的边框刷属性 [英] On LostFocus event of the text box how to change the border brush property of that text box

查看:106
本文介绍了在文本框的LostFocus事件上如何更改该文本框的边框刷属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在我的项目中,我有一个窗口,里面有一个文本框和一个按钮。我正在使用不同站点中建议的WPF和MVVM模式以获得更好的可维护性和单元测试。



在文本框的LostFocus事件中我想更改边框那个文本框的刷子属性。



你怎么建议我实现这个?



谢谢

Hi,

In my project, I have a window in which it has a text box and a button. I am using WPF with MVVM Pattern as suggested in different sites to have a better maintainability and unit testing.

On LostFocus event of the text box I want to change the border brush property of that text box.

How do you suggest me to implement this?

Thanks

推荐答案

如果你在XAML中有这个边框,给它一个名称。这将在窗口类的代码中将其公开为类实例成员。然后,您可以在代码中使用边框属性:

http://msdn.microsoft.com/en-us/library/system.windows.controls.border.borderbrush.aspx [ ^ ]。



另请参阅: http://msdn.microsoft.com/ en-us / library / system.windows.frameworkelement.name.aspx [ ^ ]。



-SA
If you have this border in XAML, give it a Name. This will expose it in the code of your window class, as a class instance member. Then you can use the properties of you border in your code:
http://msdn.microsoft.com/en-us/library/system.windows.controls.border.borderbrush.aspx[^].

See also: http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.name.aspx[^].

—SA


这篇关于在文本框的LostFocus事件上如何更改该文本框的边框刷属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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