WP7 C#代码中的图像源 [英] Image Source in WP7 C# Code
本文介绍了WP7 C#代码中的图像源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨人!!
i想做一个if语句来检查某个图像的图像源是否与一个字符串相同。
我尝试过以下方法:
Hi people!!
i wanna do a if statement to check if the image source of a certain image is the same as one string.
I have tried the following methods:
if (image6.Source.ToString() != "/2ND%20EAR;component/Images/add.jpg")
Uri uri = new Uri("/2ND%20EAR;component/Images/add.jpg", UriKind.Absolute);
ImageSource imgSource = new BitmapImage(uri);
if (image5.Source.Equals(imgSource))
但两者都不适合我。
有没有人有其他方法?
谢谢!
But both dont work for me.
Does anyone got any other method??
Thanks!
推荐答案
要获取 ImageSource 的 Uri 的字符串,只需调用 .ToString()。
因此,要完全偏执,比较两个ImageSource对象的Uri将是这样的:
To get the "String" of the Uri of the ImageSource, just call .ToString().
So, to be perfectly paranoid, to compare the Uri of two ImageSource objects would be like this:
if (0 == String.Compare(
imageSource1.ToString(),
imageSource2.ToString(),
StringComparison.OrdinalIgnoreCase))
{
...
}
我认为你应该可以使用 UriSource
来检索来源Uri并比较一下。
Off the top of my head, I would think that you should be able to use UriSource
to retrieve the source Uri and compare this.
这篇关于WP7 C#代码中的图像源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文