一开始的写法:
1 MultiBinding mb = new MultiBinding(); 2 Binding b1 = new Binding(); 3 b1.ElementName = "textBox1"; 4 b1.Path = "Tag"; 5 Binding b2 = new Binding(); 6 b2.ElementName = "textBox1"; 7 b2.Path = "Uid"; 8 mb.Bindings.Add(b1); 9 mb.Bindings.Add(b2); 10 mb.Converter = multconverter; 11 textBox1.SetBinding(TextBox.ToolTipProperty,mb);
结果刚刚绑定的时候好用,当属性Tag或者Uid改变的时候,Converter不触发导致显示不对。
然后改为下面的写法:
MultiBinding mb = new MultiBinding(); Binding b1 = new Binding("Tag"); b1.Source = textBox1; Binding b2 = new Binding("Uid"); b2.Source = textBox1; mb.Bindings.Add(b1); mb.Bindings.Add(b2); mb.Converter = multconverter; textBox1.SetBinding(TextBox.ToolTipProperty,mb);
然后就好用了T_T。
好吧 给自己写个备忘。有大牛可以帮我解答一下为嘛第一个不好用吗?