警告 Windows API 中有两个不同的ImageSource
- System.Windows.Media.ImageSource = Windows 窗体之一
- Windows.Ui.Xaml.Media.ImageSource = Windows 应用商店应用之一
我是 C# 和 Windows 8 Metro Style 应用编程方面的初学者。
但是如果您想编辑 Image
的图像,BitmapImage 的“旧”方法将不起作用:
XAML:
<Image Source="http://image.source.de" x:Name="Image1" />
C# 代码隐藏:
Image1.Source = new BitmapImage...
不会工作。编译器会说类似的话
"System.Windows.Media.Imaging.BitmapImage" can't be converted to "Windows.Ui.Xaml.Media.ImageSource"
(Yes,
BitmapImage
can usually be converted toSystem.Windows.Media.ImageSource
)
(System.Windows.Media.Imaging不在Visual Studio for Windows(StoreApps)的默认导入列表中,需要先绑定(bind)PresentationCore.dll。)
那么 - 除了使用 Binding
之外,还有什么解决方案可以编辑 Image1.Source 吗?
最佳答案
这应该有效。
Image.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new System.Uri("http://image.source.de"))
关于c# - Windows 8 C# : Windows. Ui.Xaml.Media.ImageSource 更改图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22560144/