2009-04-24 21 views
3

私は次のモデルがあります:Infragistics XamDataGridを使用して、選択したアイテムをモデルにバインドする方法は?

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}" /> 

あなたはどうしたらいいですか?

+0

これはinfragisticsフォーラムで相互投稿されています。http://news.infragistics.com/forums/p/24777/90741.aspx#90741 –

答えて

3

Infragistics forumに記載されているように、XamDataGridはIsSynchronizedWithCurrentItemプロパティを公開します。これを利用するにはObservableCollectionのListCollectionViewが必要です。このようなもの:

public ListCollectionView ElementsView {get;set;} 

// In the constructor: 
this.ElementsView = new ListCollectionView(Elements); 

次に、XamDataGridをElementsViewにバインドします。

+0

ViewModelにListCollectionViewを配置すると、リンクが見つかりませんでした。 WPFリファレンスを基になるモデルに配置したくありませんでした。どうもありがとう。 –

関連する問題