现在的位置: 首页 > 综合 > 正文

Windows Phone 7 位图编程

2012年10月28日 ⁄ 综合 ⁄ 共 1080字 ⁄ 字号 评论关闭

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

        }

窗体顶端

抱歉!评论已关闭.