C# RouteEvent“;“已加载”;在更新XML Itemssource后添加Listboxitem时不调用
我在WPF中有一个列表框,它使用指向xml文件的XMLDataProvider绑定 我在ListBoxItem的itemtemplate中设置了一个故事板,如下所示:C# RouteEvent“;“已加载”;在更新XML Itemssource后添加Listboxitem时不调用,c#,wpf,listbox,C#,Wpf,Listbox,我在WPF中有一个列表框,它使用指向xml文件的XMLDataProvider绑定 我在ListBoxItem的itemtemplate中设置了一个故事板,如下所示: <Setter Property="LayoutTransform"> <Setter.Value> <ScaleTransform x:Name="transform" /> </Se
<Setter Property="LayoutTransform">
<Setter.Value>
<ScaleTransform x:Name="transform" />
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:.2" />
<DoubleAnimation Storyboard.TargetProperty="LayoutTransform.ScaleY" From="0" Duration="0:0:.2" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
元素被添加到列表中,但情节提要不会启动。如何确保以编程方式添加的项将“已加载”事件调用到自身
更新:样式已应用于ListBox,而不是ListBoxItem。更改解决了问题。注释中提到的
Style
应应用于ListBoxItem
,这将为每个新添加的ListBoxItem应用
ListBox
loaded事件仅在第一次在UI上加载时才会引发,之后不会引发。因此,将样式从ListBox移动到ListBoxItem。样式
应用于ListBox
或ListBoxItem
?ListBox。我将停止我的案例,并更新我的问题。ThankListBox
loaded事件只有在第一次加载到UI上时才会引发,而不是之后。
MainNode.AppendChild(NewElement)