How can I check if two images have same source in wp7 C#? I am doing this but it's not working.
if(image1.source.tostring()==image2.source.tostring()){}
How can I check if two images have same source in wp7 C#? I am doing this but it's not working.
if(image1.source.tostring()==image2.source.tostring()){}
I can't see any easy way to do that. ImageSource is an abstract class and can be anything therefore it is hard to compare. However the most likely implementation is BitmapImage. So you can check of its type and if it is BitmapImage or IUriContext you can cast it and compare the BaseUri property.
You're comparing references, to compare values...
if(image1.source.ToString().Equals(image2.source.ToString())) {}
You can compare both of the images with the help of 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.");
}