将WPF ComboBox SelectedValue属性绑定到多个对象 [英] Bind WPF ComboBox SelectedValue-property to multiple objects
问题描述
假设我有一个客户列表(ObservableCollection< Customer>),每个客户都有一个状态属性.
是否可以绑定ComboBox的SelectedValue,以便它显示(has的SelectedValue,例如"WA"是指如果所有客户都将WA作为其州?
如果客户具有不同的State值,则什么都不显示,但是下拉菜单中的所有选项均可用.如果我选择OR,那么所有客户都应将其State设置为此值.
这是否可以通过XAML以及ValueConverter来完成?
或者这是代码工作吗?
Let's say I have a list of Customers (ObservableCollection<Customer>) and each Customer has a State-property.
Is it possible to bind the SelectedValue of a ComboBox, so that it shows (has a SelectedValue of) e.g. "WA" if all Customers have WA as their State?
If the customers have different State-values nothing should be shown, but all options should be available in the drop-down. If I then choose OR, then all Customers should have their State set to this value.
Is this possible to do via XAML and perhaps a ValueConverter?
Or is this a job for code-behind?
推荐答案
->如果客户具有不同的State-value,则不应使用会显示,但下拉菜单中的所有选项均应可用.如果然后选择OR,则所有客户都应将其State设置为此值.
我试图重现您的情况,但我无法完全理解您.您能提供您已经完成的工作吗?这样我才能正确理解您的真实意思,并专注于您遇到的问题?
谢谢.
Hi,
-->If the customers have different State-values nothing should be shown, but all options should be available in the drop-down. If I then choose OR, then all Customers should have their State set to this value.
I tried to repro your scenario but I can not understand you fully. could you please provide what you have already done? so that I can get your real meaning correctly and focus on the issue you are encountering?
Thanks.
这篇关于将WPF ComboBox SelectedValue属性绑定到多个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!