質問するログイン新規登録

回答編集履歴

1

コードの間違いがありました

2017/07/13 09:00

投稿

hihijiji
hihijiji

スコア4152

answer CHANGED
@@ -1,6 +1,6 @@
1
1
  そのXAMLの書き方だと DataGrid の ItemsSource にバインドしたコレクションの中の要素のプロパティにバインドしてます。
2
2
  ViewModel をバインドしているのが Window の場合は、
3
- `"{Binding Source={RelativeSource FindAncestor, AncestorType=Window}, Path=DataContext.ButtonClickCommand}"`
3
+ `"{Binding RelativeSource={RelativeSource AncestorType=Window, AncestorLevel=1}}"`
4
4
  のように指定する。
5
5
  または、ItemsSource 用の ViewModel のクラスを作ります。
6
6
  私は後者をよくやります。