CanExecuteChangedイベントハンドラに問題があります。CanExecuteChangedが正しく機能しない
私はICommandのを実装する抽象クラスがあります。
public class AddNewFilmWindowCommand : CommandBase<ViewModelCollection<FilmModel>>
{
public event EventHandler CanExecuteChanged;
public AddNewFilmWindowCommand(ViewModelCollection<FilmModel> viewModelCollection)
: base(viewModelCollection)
{
}
public override void Execute(object item)
{
this.ViewModel.NewItem = new FilmModel();
var onCanExecuteChanged = this.CanExecuteChanged;
if (onCanExecuteChanged != null)
{
onCanExecuteChanged(this, new EventArgs());
}
}
public override bool CanExecute(object parameter)
{
if (this.ViewModel.NewItem == null)
{
return true;
}
else
{
return false;
}
}
}
しかしCanExecuteChangedは私に警告与えている:
を、私は、この基本コマンドを継承するコマンドを持ってpublic abstract class CommandBase<TViewModel> : ICommand
{
protected TViewModel ViewModel { get; set; }
public event EventHandler CanExecuteChanged;
protected CommandBase(TViewModel viewModel)
{
this.ViewModel = viewModel;
}
public virtual bool CanExecute(object parameter)
{
return true;
}
public abstract void Execute(object parameter);
}
を
警告CS0108 'AddNewFilmWindowCommand.CanExecuteChanged'は継承されたメンバーを隠す 'CommandBase> .CanExeかわいいチェンジ。隠れが意図されていた場合は、新しいキーワードを使用してください。 SpravaFilmu.ViewModels
常にNULLです。このコマンドを使用してボタンをクリックすると、グレーになることはありません。
こんにちは、ありがとう、これは問題を解決:)完璧!次回はこれを覚えています! – Shadowmak