Binding with conditions

Dec 22, 2009 at 7:58 AM


I'm still new to WPFs databindingcapabilities. I'm wondering if it's possible to a datasource bind with conditions, it should be I think, but how?

What I have is a GUI with a dropdown to the right containing objects representing all languages available for a document. These objects can be checked and have a property called "IsChecked". In the middle is a "document". To the right is a dropdown containing the languages for a PART of the document.

What I want is the dropdown to the right to only contain objects that are checked in the left dropdown.

My binding for the left dropdown looks like this today:

ItemsSource="{Binding Source={x:Static Application.Current}, Path=Areas.Values}"

What I would like to do is something like this:

ItemsSource="{Binding Source={x:Static Application.Current}, Path=Areas.Values.Where(p => p.IsChecked == true)}"

Is it possible to have condition in the binding or do I have to make a template of some sort that I later on use as a datasource?


Dec 22, 2009 at 1:15 PM

I think it's no possible.

Anyway there is another way to do. Create a property in your Areas class that returns checked values or make observable collection that populates checked values