使用WPF验证规则并禁用“保存"按钮 [英] Using WPF Validation rules and the disabling of a 'Save' button

查看:210
本文介绍了使用WPF验证规则并禁用“保存"按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中有几个文本框在单击保存"按钮之前不能为空.

I have a page where a few textboxes cannot be empty before clicking a Save button.

<TextBox...

                <TextBox.Text>
                    <Binding Path ="LastName" UpdateSourceTrigger="PropertyChanged">

                        <Binding.ValidationRules>
                            <local:StringRequiredValidationRule />
                        </Binding.ValidationRules>                              
                    </Binding>
                </TextBox.Text>

我的规则有效,在输入值之前,我的文本框周围有一个红色边框.现在,我想将此验证规则添加到其他文本框中.

My rule works, I have a red border around my textbox until I enter a value. I now want to add this validation rule to my other text boxes.

在页面没有验证错误之前,如何禁用保存"按钮?我不确定要检查什么.

How do I disable the Save button until the page has no validation errors? I'm not sure what to check.

推荐答案

以下是您所需的完整示例.

Here is the complete sample what you need.

http://codeblitz.wordpress .com/2009/05/08/wpf-validation-made-easy-with-idataerrorinfo/

https://skydrive.live.com/?cid=2c6600f1c1d5e3be&amp;amp; id = 2C6600F1C1D5E3BE%21203

这篇关于使用WPF验证规则并禁用“保存"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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