I need to load an image file to WPF’s dynamic resource programmatically because the directory which contains the image files can be moved.
How can I load an image to WPF’s dynamic resource which is used like this: Source="{DynamicResource ...}" in XAML?
In XAML:
In code:
(The
Resourcescollection should be one which is in the scope of theImageof course, if you have a direct reference to theImagecontrol you can also use the immediateImage.Resources)Whenever you set a new object to that resource key the
DynamicResourcewill update.