こんにちは。
Windows10でWPF(MVVM)のアプリケーションを開発しています。
Visual Studio 2017 Communityを使っています。
###前提・実現したいこと
土台のXAMLに子どものXAMLを表示しています。
土台にあるプロパティの変化を、子で取得したいです。
###該当のソースコード
xaml
1BaseView.xaml 2<Button Content="search" Click="{Binding Search}"/>
c#
1BaseViewModel.cs 2 private bool search; 3 public bool Search 4 { 5 get { return search; } 6 set 7 { 8 searchExecuted = value; 9 RaisePropertyChanged("Search"); 10//ここで子どものButtonExecutableを呼びたい。 11 } 12 }
このSearchを子で把握したい。
xaml
1ChildView.xaml 2<Button Content="登録" 3 IsEnabled="{Binding ButtonExecutable}"/>
C#
1 public class ChildViewModel : ViewModelBase, INotifyPropertyChanged 2 { 3 private BaseViewModel baseViewModel; 4 5 public ChildViewModel() 6 { 7 baseViewModel = ServiceLocator.Current.GetInstance<BaseViewModel>(); 8 this.Initialize(); 9//コンストラクタに何か書く? 10 } 11 12 13 14 private bool buttonExecutable = false; 15 public bool ButtonExecutable 16 { 17 get { return buttonExecutable; } 18 set 19 { 20 buttonExecutable = value; 21 base.RaisePropertyChanged("ButtonExecutable"); 22 } 23 }
###補足情報(言語/FW/ツール等のバージョンなど)
Microsoft Visual Studio Community 2017
Version 15.0.26228.9 D15RTWSVC
Microsoft .NET Framework
Version 4.6.01586
です。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー