SL Setting Image.Source property to URI
Setting the Image.Source property in Silverlight XAML is pretty easy - just like you would think it would work...
<Image Source="/Assets/16_find.png" />
You can even easily bind it to the current data item using the following syntax
<Image Source="{Binding TypeImage}" />
Assuming TypeImage was a valid URI other other valid value
I recently ran into an issue when I wanted to do this in C# and set the value to a string URI.
The first thing I tried was myImage.source = "/Assets/16_find.png";
That generates a compile error because ImageSource isn't compatible with type string.
So how do yo use property to a string URI? You can use the SetValue method as you can see in the following example
imageType.SetValue(Image.SourceProperty,"/Assets/16_find.png");
References (1)
-
Response: SL Setting Image.Source property to URIIm Jahr 2003 produzierte Braunkohle 184,1 Millionen Tonnen CO2, das entsprach 22 Prozent der gesamten deutschen Emissionen. Dein schlechtes Benehmen lasse ich mir nicht gefallen.\
Reader Comments