绑定到GridControl中的选定行

时间:2016-01-25 01:03:10

标签: wpf binding grid devexpress gridcontrol

我想获得GridControl(DevExpress)中选择的对象列表

你知道我怎么能这样做吗?

<dxg:GridControl ItemsSource="{Binding Cars}">

1 个答案:

答案 0 :(得分:0)

找到了这样做的方法。

方式1

如果使用DevExpress 15.5(我不愿意),只需使用SelectedItem属性:https://documentation.devexpress.com/#WPF/DevExpressXpfGridDataControlBase_SelectedItemstopic

方式2

如果您有以下内容,则创建一个将GridView挂钩在GridControl中的行为:

<dxg:GridControl ItemsSource="{Binding Cars}">           
     <dxg:GridControl.View>
          <Controls:TableView >
            <i:Interaction.Behaviors>
              <view:CollectionObserverBehavior SelectedItems="{Binding SelectedCars}" />
            </i:Interaction.Behaviors>
          </Controls:TableView>

这篇好文章中的行为详情:http://social.technet.microsoft.com/wiki/contents/articles/22871.wpfmvvm-binding-to-read-only-properties-using-behaviors.aspx