Silverlight - Image 在 C# 中設定 Source 路徑
在XAML 裡面
要把一張網路上面圖片設定到一個Image物件裡面很簡單..
程式碼如下..
<Image Height="150" Width="200" x:Name="Image1" Source="http://www.obsessedwithfilm.com/wp-content/uploads/2009/11/passengers01.jpg"/>
但是在C# 下面是這樣寫嗎?!
Image1.Source="http://www.obsessedwithfilm.com/wp-content/uploads/2009/11/passengers01.jpg";
我相信妳Compiler出來一定會是錯的...!!
應該是這樣寫才對..
var imgSrc = "http://www.obsessedwithfilm.com/wp-content/uploads/2009/11/passengers01.jpg";
this.Image1.Source=(new BitmapImage(new Uri(imgSrc)));
我知道很簡單...
但是我就是常常忘記阿...XD
標籤:
Silverlight
|
This entry was posted on 下午6:35
and is filed under
Silverlight
.
You can follow any responses to this entry through
the RSS 2.0 feed.
You can leave a response,
or trackback from your own site.
0 意見:
張貼留言