2012-02-23 5 views
0

です。私はコレクションの子をGridView ItemsSourceにバインドします。 GridViewには国のComboBoxがあり、SampleViewModelのCountriesコレクションを取り込みたいと思います。XAMLバインディングコレクションの子項目は、私はXAMLビューへのフォロー構造を結合する際に困難を持っている別のコレクション

<Telerik:RadGridView ItemsSource="{ Binding Child }" ...> 
    <Telerik:RadGridView.Columns> 
     <Telerik:GridViewComboBoxColumn DataMemberBinding="{Binding CountryId}" 
             SelectedValueMemberPath="Id" 
             DisplayMemberPath="Name" 
             ItemsSource="{Binding ????}" /> 
     ... 
    ... 
... 

ItemsSourceはどのようなものですか。 ItemsSource = "{Binding Child}"内のルートVMのプロパティに戻るにはどうすればよいですか?

また、上記を達成するためにViewModelをどのように再構築する必要がありますか?

答えて

1

私はTelerikのコントロールでこれが動作するかどうかわからないが、通常、あなたがRelativeSource添付プロパティを経由してバインディング宣言:

{Binding Path=DataContext.Countries, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Telerik:RadGridView}}} 

もう一つの方法は、あなたのRadGridView上の名前を設定していることを使用することですElementName:

<Telerik:RadGridView ItemsSource="{ Binding Child }" x:Name="gridView"> 
... 
     <Telerik:GridViewComboBoxColumn DataMemberBinding="{Binding CountryId}" 
             SelectedValueMemberPath="Id" 
             DisplayMemberPath="Name" 
             ItemsSource="{Binding DataContext.Countries, ElementName=gridView}" /> 
+0

私の例のXAMLで愚かなタイプミスを修正した後、ElementNameの仕組みが機能します。ありがとう。 – Lepton

関連する問題