WPF MultiBinding in Convertor fails ==> DependencyProperty.UnsetValue WPF MultiBinding in Convertor fails ==> DependencyProperty.UnsetValue wpf wpf

WPF MultiBinding in Convertor fails ==> DependencyProperty.UnsetValue


When you set a list in any ItemsSource, the DataTemplate's DataContext for the individual items will each item of the list.

True that your TextBlock binding is working correctly, because the DataContext is set to your main object: PageViewModel

But in your DataTemplate the DataContext will be set to PageNumberViewModel, since these are the items in your collection.

Therefor, the binding to Path=CurrentPage.Page_Number will result to UnsetValue, because CurrentPage is not a property of PageNumberViewModel

Hope this clarifies things!

If you truly wish to bind to the CurrentPage property of your Window's DataContext, consider using an ElementName binding:

Give window a name, bind to

<Binding ElementName="name" Path="DataContext.CurrentPage.Page_Number" />

or use a RelativeSource binding:

<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}" Path="DataContext.CurrentPage.Page_Number" />


It looks like you might not have the correct DataContext to resolve the path CurrentPage.Page_Number. A good way of debugging this sort of thing is to remove the path so that you can inspect the DataContext within your value converter:

<Binding Path="." />

Then set a breakpoint in your ButtonColorConverter and have a look at exactly what you are trying to convert.


DependencyProperty.UnsetValue is merely a constant on the DependencyProperty class.

You can do something like this :

 if (values[1] == DependencyProperty.UnsetValue) {     return null;  // or default value }