windows-8 - 比较 Image.Source

标签 windows-8 windows-runtime winrt-xaml

在 WinRT 应用程序中,我有 2 个不同的图像,但来源相同:

 <Image Name="image1" Source="mySource.png"/>
 <Image Name="image2" Source="mySource.png"/>

当我将 image1.Source 与 image2.Source 进行比较时,它返回 false 。如果显示相同的图片,如何比较源以求真实?

最佳答案

您必须将Source 对象转换为位图。然后您可以比较 AbsoluteUri:

BitmapImage bm1 = (BitmapImage)image1.Source;
BitmapImage bm2 = (BitmapImage)image2.Source;

bool same = 
    (string.Compare(bm1.UriSource.AbsoluteUri, bm2.UriSource.AbsoluteUri) == 0);

关于windows-8 - 比较 Image.Source,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15721393/

相关文章:

c# - 文本框自动滚动从 wp8.1 rt 中的代码后面添加文本

背景 ImageBrush 的 XAML Storyboard

c# - 确定 Metro 应用程序正在 Windows 8 选项卡或台式电脑中运行

javascript - 如何为 Firebase 实现 Node.Js 服务器端事件监听器?

c# - 获取windows 10 UWP C#中的内存使用情况、CPU使用情况、磁盘使用情况

c# - SemanticZoom ZoomedOutView SelectedItems 返回 DependencyObject

c# - 如何禁用挂起||结束|| Windows 8 Pro上Metro Metro App的终止事件

c# - 如何在 Windows 8 上正确注册协议(protocol)处理程序?

c# - Winrt - ListView 最后一项的特定 ItemTemplate

.net - WPF/银光VS WinRT