I want to change the image of a ToggleButtonTool according to it's state. I have two GiF-images for that purpose in my project. I use the following code in the event handlers:
Uri src = new Uri(@"Images/FilterOff16x16.gif", UriKind.Relative);BitmapImage img = new BitmapImage(src);ToggleButtonRowFilteringOnOff.SmallImage = img;
Unfortunately this does not work. When I look at the BitmapImage object created in the debugger I see 'img.Metadata' threw an exception of type 'System.NotSupportedException' in the Metadata property of the object.
How can I do this properly?
Markus
It sounds like you probably have an issue with the pack notation you're using to locate the image. Taking our tools out of the equation for a second, have you tried this by just setting the Source property of an Image element? If that's not working then it has to be something with the pack notation (i.e. locating the image) or with the creation of the BitmapImage itself (in which case you may want to search the ms forums regarding the error). If it does work with an Image element then please post the sample with that working but the tool failing and we can look into why its not working in that situation.
Hi Andrew
Thanks for your answer. You are certainly right: The problem with BitmapImage has nothing to do with the Infragistics classes.
As you don't suggest another way to do it I assume that the code I provided is in principle correct for changing the image at runtime.