如果我指定祖先,则下面的组合框绑定有效,否则无效。如果我不指定祖先,为什么它不起作用?
<wpftoolkit:DataGrid Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2"
Margin="5"
BorderBrush="#A6A6A6"
BorderThickness="1"
ItemsSource="{Binding DebitListing}"
AutoGenerateColumns="False"
SelectionMode="Single">
<wpftoolkit:DataGrid.Columns>
<wpftoolkit:DataGridComboBoxColumn
Header="{Resx ResxName=MyBooks.Properties.Strings, Key=PartyListing_Party_Label}"
SelectedItemBinding="{Binding Party, ValidatesOnDataErrors=True}"
DisplayMemberPath="Name">
<wpftoolkit:DataGridComboBoxColumn.ElementStyle>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="ItemsSource" Value="{Binding Path=DataContext.CreditedAccounts, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
</Style>
</wpftoolkit:DataGridComboBoxColumn.ElementStyle>
<wpftoolkit:DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="ItemsSource" Value="{Binding Path=DataContext.CreditedAccounts, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
</Style>
</wpftoolkit:DataGridComboBoxColumn.EditingElementStyle>
</wpftoolkit:DataGridComboBoxColumn>
<wpftoolkit:DataGridTextColumn
Header="{Resx ResxName=MyBooks.Properties.Strings, Key=PartyListing_Amount_Label}"
Binding="{Binding Amount, ValidatesOnDataErrors=True}"/>
</wpftoolkit:DataGrid.Columns>
</wpftoolkit:DataGrid>