使用 Command 时禁用 Xamarin.Forms、MvvmCross 中的按钮的最佳做法是什么?

What's the best practice to disable a button in Xamarin.Forms, MvvmCross, when using Command?

我在 Xamarin.Forms MvvmCross 项目中禁用按钮的命令时遇到了一些麻烦。 IsEnabled 似乎无法正常工作,即使使用 CanExecute 属性.

在页面的yaml文件中:

<Button Text="DoSomething" Command="{Binding DoSomethingCommand}" IsEnabled="{Binding DoSomethingIsEnabled}"/>

在视图模型上:

public IMvxCommand DoSomethingCommand => new MvxCommand(() => System.Diagnostics.Debug.WriteLine("Is enabled!"));

or 

public IMvxCommand DeviceButtonCommand => new MvxCommand(() => System.Diagnostics.Debug.WriteLine("Is enabled!"), () => DoSomethingIsEnabled);

我看了一些关于它的帖子,但我还没有解决问题,不知道吗?

我认为当您更改 CanExecute 委托中指定的 属性 时,您需要在命令上调用一个方法。 类似于 XF 的 ChangeCanExecute() 。 而且我不记得 mvvmcross 的名字 :)

已编辑:RaiseCanExecuteChanged 用于 MvvmCross。

private bool _doSomethingIsEnabled;
public bool DoSomethingIsEnabled
{
    get => _doSomethingIsEnabled;
    set
    {
        _doSomethingIsEnabled = value;
        DoSomethingCommand.ChangeCanExecute();
    }
}