C# 绑定到DataGridRowHeader中的集合未按预期工作

C# 绑定到DataGridRowHeader中的集合未按预期工作,c#,wpf,xaml,data-binding,datagrid,C#,Wpf,Xaml,Data Binding,Datagrid,我的DataGrid绑定到一个ObservableCollection 第一个绑定正在工作,而第二个绑定没有工作 在VisualStudio的输出窗口中仍然没有BindingError 我需要显示每个条目的类型,以便通过索引进行访问不起作用。这应该可以: <ComboBox ItemsSource="{Binding DataContext.Types, RelativeSource={RelativeSource AncestorType=DataGridRowHeader}}" /&g

我的DataGrid绑定到一个ObservableCollection

第一个绑定正在工作,而第二个绑定没有工作

在VisualStudio的输出窗口中仍然没有BindingError

我需要显示每个条目的类型,以便通过索引进行访问不起作用。

这应该可以:

<ComboBox ItemsSource="{Binding DataContext.Types, RelativeSource={RelativeSource AncestorType=DataGridRowHeader}}" />

它正在工作!非常感谢!这是否意味着无法识别绑定来自DataGridRowHeader?是的,DataTemplate不会从DataGridRowHeader继承DataContext。
<DataGrid ItemsSource="{Binding Entries}">
    <DataGrid.RowHeaderTemplate>
       <DataTemplate>
          <Border Width="100">
              <StackPanel>                                
                  <ComboBox ItemsSource="{Binding DataContext.Entries[0].Types, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" />
                  <ComboBox ItemsSource="{Binding Types}" />
              </StackPanel>
          </Border>
      </DataTemplate>
   </DataGrid.RowHeaderTemplate>
</DataGrid>
<ComboBox ItemsSource="{Binding DataContext.Types, RelativeSource={RelativeSource AncestorType=DataGridRowHeader}}" />