Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1080
Programatically change image of a ToggleButtonTool
posted

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

Parents
No Data
Reply
  • 54937
    Suggested Answer
    Offline posted

    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.

Children