![](/img/trans.png)
[英]How to move 2 images at the same time in C# for Windows Phone App?
[英]how to check if sources of two images are same in Windows Phone 7 and C#?
如何在wp7 C#中检查两个图像是否具有相同的源? 我这样做但是没有用。
if(image1.source.tostring()==image2.source.tostring()){}
我看不到任何简单的方法。 ImageSource是一个抽象类,可以是任何东西,因此很难比较。 但最可能的实现是BitmapImage 。 所以,你可以检查它的类型,如果是的BitmapImage或IUriContext你可以施放它和比较基本URI属性。
您正在比较参考,比较值...
if(image1.source.ToString().Equals(image2.source.ToString())) {}
您可以在BitmapImage的帮助下比较两个图像
BitmapImage image1= new BitmapImage(new Uri("your first image relative path", UriKind.Relative))
BitmapImage image2= new BitmapImage(new Uri("your second image relative path", UriKind.Relative))
if(image1==image2)
{
MessageBox.show("Image matched.");
}
else
{
MessageBox.Show("Not matched.");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.