WPF 关联多重绑定和转换器的值[]
我的 XAML 如下所示
<Button.IsEnabled >
<MultiBinding Converter="{StaticResource IsEnabledConverter}" >
<Binding Path="aaa"/>
<Binding Path="bbb"/>
<Binding Path="ccc"/>
<Binding Path="ddd"/>
<Binding Path="eee"/>
<Binding Path="fff"/>
<Binding Path="ggg"/>
<Binding Path="hhh"/>
<Binding Path="iii"/>
<Binding Path="jjj"/>
</MultiBinding>
</Button.IsEnabled>
现在在我的 Convert 函数中我得到 10 个值,并且保持值集合的绑定序列和索引号同步是一件令人头痛的事情。必须有更好的方法来连接这两者。怎样做?
My XAML is as follows
<Button.IsEnabled >
<MultiBinding Converter="{StaticResource IsEnabledConverter}" >
<Binding Path="aaa"/>
<Binding Path="bbb"/>
<Binding Path="ccc"/>
<Binding Path="ddd"/>
<Binding Path="eee"/>
<Binding Path="fff"/>
<Binding Path="ggg"/>
<Binding Path="hhh"/>
<Binding Path="iii"/>
<Binding Path="jjj"/>
</MultiBinding>
</Button.IsEnabled>
Now in my Convert function i get 10 values and its a headache to keep the binding sequence and index number of values collection in sync. There has to be a better way to connect these two. How to?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根本不使用转换器,而是将其绑定到视图模型中执行转换的
属性
Instead of using a converter at all, bind it to a property in your viewmodel that does the conversion
虽然拥有视图模型是一种更好的方法,但对于那些不使用视图模型或无法修改现有视图模型的人,请查看我的帖子:http://technologyandme.blogspot.com/2010/07/wpf-converter-values.html
Although having View-Model would be a better way, for those who are not using view-model, or cannot modify existing view-model, check out my post : http://technologyandme.blogspot.com/2010/07/wpf-converter-values.html