我在用户控件中有一个网格并分配了一个数据上下文
<Grid x:Name="GrdContainer" DataContext="{Binding FormAttributeMappings,Mode= TwoWay}" DataContextChanged="GrdContainer_DataContextChanged" UseLayoutRounding="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5"/>
</Grid.ColumnDefinitions>
private void GrdContainer_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
......
}
当我被分配List<FormAttributeMapping> FormAttributeMappings
为 DatacontextGrdContainer_DataContextChanged
时会被触发,但是当我在 Grid datacontex source( FormAttributeMappings.add(FormAttributeMapping)
) 中添加一些项目时GrdContainer_DataContextChanged
不会触发