I have a ComboBox that has it's ItemsSource bound as
ItemsSource="{Binding Source={StaticResource documentTemplates}}"
Where documentTemplates is
<ObjectDataProvider x:Key="documentTemplates"
ObjectType="{x:Type Core:DataHelper}"
MethodName="GetDocumentTemplates"/>
The problem I have is that the document templates defined in the database could be changed by other areas of the application (or indeed by another user) and so I want to have the ItemsSource requery each time. At the moment, once the resource has been populated it will never requery. I assume that this is because it is a StaticResource, but if I swap this for a DynamicResource I get
A 'DynamicResourceExtension' cannot be set on the 'Source' property of type 'Binding'. A 'DynamicResrouceExtension' can only be set on a DependencyProperty or a DependencyObject
How should I go about fixing this?
Keep your XAML as is and whenever a requery is needed call Refresh on the ObjectDataProvider.
(FindResource("documentTemplates") as ObjectDataProvider).Refresh();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With