为什么要使用多重绑定转换器?
难道我不能只使用单个绑定转换器并作为 DataContext 中的参数传递,然后从那里选择我想要使用的属性吗?
Couldn't I just use a single binding converter and as a parameter pass in the DataContext and from there pick what properties I want to use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果传递整个对象而不是各个属性,则当各个属性更改时,将不会重新计算绑定表达式。您将失去
INotifyPropertyChanged
机制的好处。If you pass the whole object instead of the individual properties, then the binding expression will not be re-evaluated when the individual properties change. You will be losing the benefit of the
INotifyPropertyChanged
mechanism.您可能想要更明确并接受最少的额外信息(这通常是良好的编程实践),或者您可能需要来自多个来源的信息 - 例如,您的值可能取决于数据上下文和检查的属性视图中其他位置的复选框的状态。
You might want to be more explicit and take in the minimum extra information (which is just generally good programming practice), or you may want information from more than one source - e.g. Your value might be dependent on a property of the datacontext and the checked state of a checkbox somewhere else in the view.
您可以这样做,但如果相关属性发生这种变化,绑定将不会更新。除了更新之外,还需要多重绑定来实现与不同控件和数据对象的更复杂的绑定。
You can do that, but the binding will not update if the relevant properties change that way. Besides the updates Multibinding is needed for more complex bindings to different controls and data-objects.