我有以下模型:
public class Model : INotifyPropertyChanged
{
public ObservableCollection<ViewElement> Elements { get; set; }
public ViewElement CurrentElement { get; set; }
}和下面的网格,其中父DataContext是上面的模型:
<dg:XamDataGrid DataSource="{Binding Path=Elements}" />我希望将CurrentElement属性绑定到网格的选定项,类似于在ListView中所做的操作
<ListView x:Name="playbackSteps"
ItemsSource="{Binding Path=Elements}"
SelectedItem="{Binding Path=CurrentElement}" />你建议我怎么做?
发布于 2009-04-24 14:44:56
正如Infragistics forum中所述,XamDataGrid公开了一个IsSynchronizedWithCurrentItem属性。要利用这一点,您需要一个ObservableCollection的ListCollectionView。如下所示:
public ListCollectionView ElementsView {get;set;}
// In the constructor:
this.ElementsView = new ListCollectionView(Elements);然后将您的XamDataGrid绑定到ElementsView。
https://stackoverflow.com/questions/785607
复制相似问题