C#, C♯, C#相談室 Part91at TECH
C#, C♯, C#相談室 Part91 - 暇つぶし2ch172:デフォルトの名無しさん
16/11/11 07:08:21.41 KgVthd+h.net
いい例がある。これならわかる。これを逃してしてしまうと永久にわからないというほどの
優れた例を提示しておく。
優れた例
XAML
<TextBox Text="{Binding Name}"/>
<Button Content="実行" Command="{Binding ExecuteCommand}"/>
<Label Content="{Binding Result}"/>
ViewModel
  public DelegateCommand ExecuteCommand { get; }
public MainWindowViewModel(){
ExecuteCommand = new DelegateCommand(() => Result = "登録OK", CanExecute);
}
private bool CanExecute(){
return !string.IsNullOrWhiteSpace(Name);
}
private string _name;
public string Name{
get { return _name; }
set { if (OnPropertyChanged(ref _name, value)) ExecuteCommand.RaiseCanExecuteChanged();}
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch