Windows 8 C#:Windows.Ui.Xaml.Media.ImageSource更改图像 [英] Windows 8 C#: Windows.Ui.Xaml.Media.ImageSource change Image

查看:160
本文介绍了Windows 8 C#:Windows.Ui.Xaml.Media.ImageSource更改图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

警告 Windows API中有两个不同的ImageSource

WARNING There are two different ImageSources in Windows API

  • System.Windows.Media.ImageSource = Windows窗体之一
  • Windows.Ui.Xaml.Media.ImageSource = Windows Store应用程序之一

我是C#和Windows 8 Metro Style App编程知识的初学者.

I'm a beginner in C# and Windows 8 Metro Style App programming stuff.

但是,如果您要编辑Image的图像,则使用BitmapImage的旧"方法将不起作用:

But if you want to edit the image of a Image, the "old" method with BitmapImage won't work:

XAML:

<Image Source="http://image.source.de" x:Name="Image1" />

代码隐藏的C#:

Image1.Source = new BitmapImage...

不起作用.编译器会说类似

won't work. The compiler will say something like

"System.Windows.Media.Imaging.BitmapImage"无法转换为"Windows.Ui.Xaml.Media.ImageSource"

"System.Windows.Media.Imaging.BitmapImage" can't be converted to "Windows.Ui.Xaml.Media.ImageSource"

(是的,BitmapImage通常可以转换为System.Windows.Media.ImageSource)

(Yes, BitmapImage can usually be converted to System.Windows.Media.ImageSource)

(System.Windows.Media.Imaging不再位于Visual Studio for Windows(StoreApps)的默认导入列表中,您需要首先绑定PresentationCore.dll.)

(System.Windows.Media.Imaging isn't anymore in the default import list of Visual Studio for Windows (StoreApps), you need to bind PresentationCore.dll first.)

那么-与使用Binding s相比,有什么解决方案可以编辑Image1.Source?

So - is there any solution to edit Image1.Source than using Bindings?

推荐答案

这应该有效.

Image.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new System.Uri("http://image.source.de"))

这篇关于Windows 8 C#:Windows.Ui.Xaml.Media.ImageSource更改图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆