C# 检查ImageSource是否为空

C# 检查ImageSource是否为空,c#,binding,windows-phone,C#,Binding,Windows Phone,我正在使用Binding到Image.SourcePropertyfrombyte[]变量。在IValueConverter中,我检查value.Length>0,如果是,则根据其值设置源代码。然后我需要知道,如果设置了,那么我可以显示或隐藏清除按钮图像。源代码始终不为空。如果它是从字节[]数组设置的,怎么知道呢? 我的代码: 现在我需要代码来检查是否设置了图像源属性: // myImage.Source always != null even if there was no bmp.SetSo

我正在使用
Binding
Image.SourceProperty
from
byte[]
变量。在
IValueConverter
中,我检查
value.Length>0
,如果是,则根据其值设置源代码。然后我需要知道,如果设置了,那么我可以显示或隐藏清除按钮<代码>图像。源代码始终不为空。如果它是从
字节[]
数组设置的,怎么知道呢? 我的代码:

现在我需要代码来检查是否设置了图像源属性:

// myImage.Source always != null even if there was no bmp.SetSource() call
var str = myImage.Source != null ? "Image is set" : "Image is empty";
诸如此类

if (((BitmapImage)myImage.Source).UriSource == null)
{
 //Image is empty
}


你能澄清你的问题吗?我不知道我是否理解你的想法?
if (((BitmapImage)myImage.Source).UriSource == null)
{
 //Image is empty
}
var str = ((BitmapImage)myImage.Source).UriSource != null ? "Image is set" : "Image is empty";