首页 新闻 会员 周边

关于WPF的一个问题

0
悬赏园豆:20 [已解决问题] 解决于 2012-09-06 11:51

各位大侠。我在写WPF的时候遇到这样的一个问题。麻烦大侠给点答案。

 1 // 这个类是进行数据验证的
 2 public class LoginMultiBinding : IMultiValueConverter
 3     {
 4         #region IMultiValueConverter メンバー
 5 
 6         public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 7         {
 8             if (!values.Cast<string>().Any(text => string.IsNullOrEmpty(text)))
 9             {
10                 return true;
11             }
12             return false;
13         }
14 
15         public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
16         {
17             throw new NotImplementedException();
18         }
19 
20         #endregion
21     }
22 
23 
24 // 这是登陆界面的后台。
25 public Login()
26         {
27             InitializeComponent();
28             this.SetConstraint();
29         }
30 
31         /// <summary>
32         /// 设置约束条件
33         /// </summary>
34         private void SetConstraint() 
35         {
36             Binding bind1 = new Binding("Text") { Source = txtUserName };
37             Binding bind2 = new Binding("Password") { Source = txtUserPwd }; 
38 
39             MultiBinding mulBind = new MultiBinding() { Mode = BindingMode.OneWay };
40             mulBind.Bindings.Add(bind1);
41             mulBind.Bindings.Add(bind2);
42             mulBind.Converter = new LoginMultiBinding();
43             this.btnLogin.SetBinding(Button.IsEnabledProperty, mulBind);
44         }

不知道为什么在数据验证的时候values这个数组就是获取不到密码框输入的值。麻烦给点意见啊。

 

我查了下,这个密码框的PASSWORD属性不是依赖属性。大家有没有什么其他方法啊。

WPF
HeartDawn的主页 HeartDawn | 初学一级 | 园豆:9
提问于:2012-08-29 13:57
< >
分享
最佳答案
0

WPF 里密码框绑定是不起作用的!!!!

收获园豆:20
Jeremy Liu | 小虾三级 |园豆:705 | 2012-08-29 18:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册