虚位以待(AD)
虚位以待(AD)
首页 > 软件编程 > WindowsPhone/WindowsMobile > Windows Phone开发之图片控件Image及定义URI

Windows Phone开发之图片控件Image及定义URI
类别:WindowsPhone/WindowsMobile   作者:码皇   来源:互联网   点击:

图片控件Image的使用如下:[html]<Image Grid Column="1" Grid ColumnSpan="3" Grid Row="5" Grid RowSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="image1" Stretch="Uni
 图片控件Image的使用如下:

 

[html]
<Image Grid.Column="1"  
               Grid.ColumnSpan="3" 
               Grid.Row="5"  
               Grid.RowSpan="2"  
               VerticalAlignment="Stretch" 
               HorizontalAlignment="Stretch"               
               Name="image1"  
               Stretch="UniformToFill"  
               Source="/PhoneApp4;component/Images/Jellyfish.jpg"  
               Margin="8,0,72,0" /> 
解释:
Stretch="UniformToFill" 可以调整大小有拉伸效果
Stretch="Fill" 任意拉伸调整大小
Stretch="Uniform" 按照原图比例调整大小
Source="/PhoneApp4;component/Images/Jellyfish.jpg" 图片引用路径

后台代码修改图片:
 System.Windows.Media.Imaging.BitmapImage myImage = new BitmapImage();
 myImage.UriSource = new Uri("/PhoneApp4;component/Images/Tulips.jpg", UriKind.Relative);
 image1.Source = myImage;

 


摘自 whuarui2010的专栏

相关热词搜索: Windows Phone 开发