B
Brendan Haddock
I am trying to create an ItemsControl which is bound to an
ObservableCollection using the ItemsSource property. I want to use a
different ItemTemplate for different items in the collection using the
ItemTemplateSelector. I've set this up, and it seems to be working
properly, except for one problem. If I edit an item in the
ObservableCollection, the ItemTemplate is not updated. My WPF application
does not call the SelectTemplate method of my ItemTemplateSelector when an
item in the collection is updated, only when a new item is added. I believe
the collection is being updated properly; the changes to the data show up in
the ItemsControl, the template just does not change. The items in my
collection implement INotifyPropertyChanged, so I believe the ItemsControl
is properly notified about data changes.
Is SelectTemplate supposed to be called when an item in a collection is
edited, or is this just a limitation in WPF? I am fairly new to C# and WPF,
so I could be doing something wrong. Please help me figure out what I'm
doing wrong, or let me know if WPF is designed to just call SelectTemplate
when an item is first added, and not when it is updated.
Thank you,
Brendan
ObservableCollection using the ItemsSource property. I want to use a
different ItemTemplate for different items in the collection using the
ItemTemplateSelector. I've set this up, and it seems to be working
properly, except for one problem. If I edit an item in the
ObservableCollection, the ItemTemplate is not updated. My WPF application
does not call the SelectTemplate method of my ItemTemplateSelector when an
item in the collection is updated, only when a new item is added. I believe
the collection is being updated properly; the changes to the data show up in
the ItemsControl, the template just does not change. The items in my
collection implement INotifyPropertyChanged, so I believe the ItemsControl
is properly notified about data changes.
Is SelectTemplate supposed to be called when an item in a collection is
edited, or is this just a limitation in WPF? I am fairly new to C# and WPF,
so I could be doing something wrong. Please help me figure out what I'm
doing wrong, or let me know if WPF is designed to just call SelectTemplate
when an item is first added, and not when it is updated.
Thank you,
Brendan