views:

515

answers:

1

Let's say I have a list of Customers (List) 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 is shown. But if I then choose OR, then all Customers should have their State set to this value.

I've accompliced it through a ValueConverter, where I use the Convert method to return the value of the State-property if they're all the same, and null if not. In this method the value-parameter is a List...

But in the ConvertBack method I don't have access to the List object, but could set the parameter object to the List object i XAML when setting up the binding, and then setting the State-property manually on all Customers, but that just doesn't feel right!

Is there any other way to do this?

+1  A: 

Well - forgot to update this questing with my solution.

On my ValueConverter I have a private List parameter, where I add all selected customers if they have the same State-property.

Then in the ConvertBack-method I just update the State of all the Customer-objects in the List...

kennethkryger
Just wanted to second your solution. That's how I would have approached it, too, I believe.
MojoFilter