ComboBox ItemsSource from MarkupExtension SelectedItem out of sync

56 Views Asked by At

I am struggling with the following.

I want to set a ComboBox's ItemsSource with a object collection provided from a MarkupExtension.

Such as: ItemsSource="{ex:ItemsSource ModelType=m:Category}" where ItemsSource is a class ItemsSourceExtension deriving from MarkupExtension.

Problem is that when doing so, the ComboBox's SelectedItem is null although its binding source has a value.

ComboBox Selected Item is null ComboBox Selected Item is null I have tried a lot. Have tried deriving from MarkupExtension and also tried subclassing Binding to no avail.

I want to simulate the use of a standard Binding, where it works fine.

Such as: ItemsSource="{Binding DataContext.Categories, RelativeSource={RelativeSource AncestorType=v:DetailView}}"

Result: This is how it should be

1

There are 1 best solutions below

0
On

Finally figured it out. The ItemsSource object collection provided by the MarkupExtension were originating from different EntityFramework DbContext instances.