MVVM.i でデータグリッドのセル値を取得する方法は、何も選択していません。2 行目の最初の列の値が必要です。
1 に答える
1
通常、Datagrind は Viewmodel のプロパティにバインドされます。Viewmodel でそのプロパティにアクセスして、必要な値を取得するだけです。
ViewModel にはプロパティがあります。
public ObservableCollection<Characteristic> Items{get;set;}
特性クラス
public class Characteristic : ObservableObject
{
private string _name;
public string Name
{
get { return _name; }
set
{
_name = value;
RaisePropertyChanged("Name");
}
}
}
XAML の場合:
<DataGrid Margin="0" Grid.Row="1" ItemsSource="{Binding Items}" AutoGenerateColumns="True" />
ViewModel の Items プロパティにアクセスして、コレクションの 2 番目の項目を取得するだけです。
于 2012-09-11T11:02:05.607 に答える