c# - Convert imagesource to string -


i have code:

if (myimage.source == "ms-appx:///assets/myimage.png") {    //do } 

but error:

cannot implicitly convert type 'string' 'windows.ui.xaml.media.imagesource' 

so how convert imagesource string can compare them? tried tostring() doesn't seem work.

the image's source property imagesource type, not string.

as per documentation imagesource:

an object represents image source file drawn image. typically set bitmapimage object, constructed uri describes path valid image source file. or, can initialize bitmapsource stream, perhaps stream storage file.

[updated:] therefore, need 2 things: 1. determine type of image source 2. if it's bitmapimage, check bitmap's urisource expected uri:

var imguri = new uri("ms:app:///assets/splashscreen.scale-100.png"); img.source = new bitmapimage(imguri);  if (img.source.gettype() == typeof(bitmapimage)     && (img.source bitmapimage).urisource.equals(imguri)) {     // useful here!  } 

hth.