C# WPF列表框项目ContainerStyle

C# WPF列表框项目ContainerStyle,c#,wpf,listbox,mouseevent,C#,Wpf,Listbox,Mouseevent,我对ItemsContainerStyle有一个奇怪的问题。我为ItemsContainerStyle定义了两种不同的样式: <Style x:Key="LeftAligned"> <Setter Property="FrameworkElement.HorizontalAlignment" Value="Left" /> </Style> <Style x:Key="FullSelectionBox"> <Setter Proper

我对ItemsContainerStyle有一个奇怪的问题。我为ItemsContainerStyle定义了两种不同的样式:

<Style x:Key="LeftAligned">
  <Setter Property="FrameworkElement.HorizontalAlignment" Value="Left" />
</Style>
<Style x:Key="FullSelectionBox">
  <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch" />
</Style>

更改样式后,PreviewMouseLeftButtonUp、PreviewMouseRightButtonUp或PreviewMouseUp事件不会以正确的方式触发。在大多数情况下,这是俄罗斯轮盘赌,如果事件发生与否

你知道为什么我的应用程序会有这种奇怪的行为吗

LogViewer.ItemContainerStyle = (Style) FindResource ("FullSelectionBox");
LogViewer.ItemContainerStyle = (Style) FindResource ("LeftAligned");