我有一个按钮的委托命令。我想在radgridview中选择一行,然后单击按钮以获取行信息。
观点:
<telerik:RadGridView Name="playersGrid"
ItemsSource="{Binding Players}"
AutoGenerateColumns="False" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Number}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
我的ViewModel是
private object selectedItem;
public object SelectedItem
{
get { return this.selectedItem; }
set
{
if (value != this.selectedItem)
{
this.selectedItem = value;
this.OnPropertyChanged("SelectedItem");
}
}
}
protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
handler(this, args);
}
}
private void OnPropertyChanged(string propertyName)
{
this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
}
private void Click_CreateButton(object param)
{
// get row selectedItem
}
有可能吗?