WPF 中的错误提供程序
我正在工具箱中查看 WPF 组件,但找不到 2005/2008 中出现的错误提供程序。
被移除了吗?
I am looking at WPF componenents in the toolbox but I cannot find the error provider that is present in 2005/2008.
Is it removed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ErrorProvider 是一个 Winforms 控件。 WPF 中没有类似的东西。但如果您创建一个 win forms 项目,您仍然可以在 Visual Studio 2008 中找到它。
您可能需要查看这篇有关 WPF 中的错误验证的文章。它对于如何处理验证提供了一些有用的建议和想法。
the ErrorProvider is a Winforms control. There is no equivalent in WPF. But you will still be able to find in in visual studio 2008 if you create a win forms project.
You might want to take a look at this article on error validation in WPF. It has some useful suggestions and ideas for how to handle validation.
.NET 3.5 添加了对 IDataErrorInfo 的 WPF 支持:.NET 3.5 中的数据验证。
.NET 3.5 added WPF support for IDataErrorInfo: Data validation in .NET 3.5.
首先请原谅我评论如此古老的讨论,但这可能会有所帮助,因为我有完全相同的问题,西蒙的链接帮助我“从某件事开始”
我可以测试西蒙 P.史蒂文斯教程,但老实说我不喜欢它就这么多:
我认为使用 MVVM 非常适合管理任何情况:
我设置了 TextBox、BorderBrush 和 ToolTip,根据我的情况,我将隐藏/显示 ToolTip 和颜色边框:
XAML:
代码隐藏(LostFocus = 留给习惯的人) WindowsForm) :
然后是 ViewModel :
当规则针对具体情况时非常有用。
First excuse me for commenting a such old discussion, but this could help as I had exactly the same question, and Simon's link helped me to "begin with something"
I could test Simon P.Stevens tutorial, but honestly I didn't like it that much :
I think using MVVM is very well adapted to manage any situation :
I set my TextBox, with a BorderBrush , and ToolTip, regarding my conditions I will Hide/Display ToolTip and color border :
XAML :
Code Behind (LostFocus = Leave for whom used to WindowsForm) :
Then ViewModel :
Just very useful when rules are specific regarding the situation.