Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
データグリッドで MVVM を使用する wpf アプリケーションがあります。viewModel で selectedIndex プロパティを設定しましたが、SelectedItems プロパティが空です。選択した項目を選択するべきではありませんか?
必ずしも。
これを行う 1 つの方法は、データグリッド xaml の SelectedItem プロパティを、INotifyPropertyChanged を実装するビュー モデルのプロパティに設定することです。次に、xaml バインディング モードを双方向に設定します。
次に、選択した項目をクリックすると、xaml バインディングからの変更がトリガーされ、ビュー モデルの値が更新されます。