« Licensing Team System for your build machine | Main | Debugging FullScreen Silverlight On a Single Monitor »

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");

Posted on Thursday, March 6, 2008 at 05:51PM by Registered CommenterDavid Yack | CommentsPost a Comment | References1 Reference

References (1)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
    Im 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

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>