뷰 및 modelview 개체가 인스턴스화되어주의가 산만 해졌습니다. 예 : 보기 Vlistview LV 및 버튼이 있습니다. 버튼에는 매개 변수로 사용되는 바운드 명령 인 listview LV이 있습니다. 명령 CanExecute 메서드는 listView LV에 요소가 있는지 여부를 확인합니다. 하지만 내가 열 때 보기 V보기 모델 개체는 보기 전에 생성됩니다 않습니다. 따라서 CanExecture 메서드가 listView을 검사하면 null이고 내 버튼은 영원히 사용할 수 없게됩니다.WPF View 및 ModelView 만들기
어떻게 해결할 수 있습니까?
편집 : 명령 실행 : 명령 구현의 종류
public class DelegateCommand : ICommand
{
public event EventHandler CanExecuteChanged;
private readonly Action<object> _execute;
private readonly Func<object, bool> _canExecute;
public DelegateCommand(Action<object> execute, Func<object, bool> canExecute = null)
{
if (execute == null)
{
throw new ArgumentNullException(nameof(execute));
}
this._execute = execute;
this._canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return _canExecute == null || _canExecute(parameter);
}
public void Execute(object parameter)
{
_execute(parameter);
}
public void RaiseCanExecuteChanged()
{
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
}
당신은 명령 implementaion/당신이 명령에 사용하는 프레임 워크를 게시 할 수 있습니까? – JanDotNet