下面是我的xaml代码,其中我将imagesource绑定到imagebrus
<Ellipse>
<Ellipse.Fill>
<ImageBrush ImageSource="{Binding SnapshotTaken}" />
</Ellipse.Fill>
</Ellipse>
c#,下面是我从
绑定imagesource的代码 public ImageSource SnapshotTaken
{
get => mSnapshotTaken;
set
{
if (value == null)
{
SnapshotToByte = null;
}
else
{
mSnapshotTaken = value;
//SnapshotToByte = ConvertImageTo.ConvertBitmapSourceToByteArray(mSnapshotTaken);
OnPropertyChanged("SnapshotTaken");
}
}
}
上面的代码工作正常。 问题是如何在清除命令时清除图像。 下面的代码不起作用
private ICommand mClearImageCommand;
public ICommand ClearImageCommand
{
get
{
if (mClearImageCommand == null)
{
mClearImageCommand = new DelegateCommand(delegate ()
{
SnapshotTaken = null;
});
}
return mClearImageCommand;
}
}