How do you set Image.Source in Silverlight(Code behind)
问题 I am dynamically generating an image through code-behind in Silverlight and apparently the image source doesn't accept a string or Uri as a path. How can I set the source? 回答1: How do you mean it won't accept a string as source? Are you not able to do this? Or are you saying your image is in memory and you don't know how to reference it? this.MyImage.Source = new BitmapImage(new Uri("/MyNameSpace;images/someimage.png", UriKind.Relative)); 回答2: // create a new image Image image = new Image();