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.
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}}"
Finally figured it out. The ItemsSource
object collection provided by the MarkupExtension
were originating from different EntityFramework
DbContext
instances.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.