Windows Phone 7 點陣圖程式設計

weixin_33763244發表於2017-11-14

Image控制元件的寫法

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

<Image Name="img" />

</Grid>

 

 

 

通過System.Windows.Controls.Control.ManipulationStarted事件來進行呼叫這這個方法覆蓋了System.Windows.UIElement.OnManipulationStarted(System.Windows.Input.ManipulationStartedEventArgs)。

載入網路的圖片資源

protected override void OnManipulationStarted(ManipulationStartedEventArgs args)

{

Uri uri = new Uri("http://www.website.com/image/a.jpg");

BitmapImage bmp = new BitmapImage(uri);

img.Source = bmp;

 

args.Complete();

args.Handled = true;

base.OnManipulationStarted(args);

}

 

載入本地的圖片資源

protected override void OnManipulationStarted(ManipulationStartedEventArgs args)

{

Uri uri = new Uri("../Images/Hello.png", UriKind.Relative);

StreamResourceInfo resourceInfo = Application.GetResourceStream(uri);

BitmapImage bmp = new BitmapImage();

bmp.SetSource(resourceInfo.Stream);

img.Source = bmp;

 

args.Complete();

args.Handled = true;

base.OnManipulationStarted(args);

}

窗體頂端


本文轉自linzheng 51CTO部落格,原文連結:http://blog.51cto.com/linzheng/1079238


 

相關文章