PreviewMouseLeftButtonDown防止SelectionChanged事件

| 我在画布上有ListBoxItems。我可以使用ScrollViewer通过一些Mouse事件在画布上拖动和滚动视图。这些鼠标事件似乎会覆盖嵌套在ScrollViewer中的ListBox的SelectionChanged事件,或者永远不会做出选择,因为鼠标事件会在ListBox捕获之前捕获单击。如果有人对这个问题有任何解决方案,将不胜感激。感谢您的时间,这是我的代码。 XAML:
        <ScrollViewer x:Name=\"objScrollViewer\"
                      Grid.Row=\"0\"
                      Grid.Column=\"1\"
                      VerticalScrollBarVisibility=\"Hidden\"
                      HorizontalScrollBarVisibility=\"Hidden\"
                      HorizontalAlignment=\"Stretch\"
                      VerticalAlignment=\"Stretch\"
                      MouseLeftButtonUp =\"OnMouseLeftButtonUp\"
                      PreviewMouseLeftButtonUp =\"OnMouseLeftButtonUp\"
                      PreviewMouseLeftButtonDown=\"OnPreviewMouseLeftButtonDown\"
                      PreviewMouseMove=\"OnPreviewMouseMove\"
                      PreviewMouseUp=\"OnPreviewMouseUp\"
                      ScrollChanged=\"OnScrollViewerScrollChanged\">

            <ListBox x:Name=\"objCoreViewer\"
                     ItemsSource=\"{Binding ItemsSource}\"
                     Background=\"Transparent\"
                     SelectionChanged=\"objCoreViewer_SelectionChanged\"
                     ItemTemplateSelector=\"{DynamicResource CoreViewerDataTemplateSelector}\"
                     ItemContainerStyleSelector=\"{DynamicResource ItemContainerStyleSelector}\"
                     PreviewMouseWheel=\"objCoreViewer_PreviewMouseWheel\">

                <!-- Core Map Canvas -->

                <ListBox.ItemsPanel>

                    <ItemsPanelTemplate>
                        <local:CoreViewerCanvas x:Name=\"objCoreViewerCanvas\"
                                Background=\"Transparent\"
                                ClipToBounds=\"True\">
                            <local:CoreViewerCanvas.LayoutTransform>
                                <ScaleTransform ScaleX=\"{Binding Path=Value, ElementName=ZoomSlider}\"
                                                ScaleY=\"{Binding Path=Value, ElementName=ZoomSlider}\" />
                            </local:CoreViewerCanvas.LayoutTransform>
                        </local:CoreViewerCanvas>
                    </ItemsPanelTemplate>

                </ListBox.ItemsPanel>

            </ListBox>

        </ScrollViewer>
C#: 这永远不会被称为
    private void objCoreViewer_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
    }
这确实被称为
    private void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        var mousePos = e.GetPosition(objScrollViewer);
        if (mousePos.X <= objScrollViewer.ViewportWidth && mousePos.Y < 
            objScrollViewer.ViewportHeight)
        {
            objScrollViewer.Cursor = Cursors.SizeAll;
            lastDragPoint = mousePos;
            Mouse.Capture(objScrollViewer);
        }
    }
编辑1: 我将ScrollViewer事件属性从PreviewMouseLeftButtonDown更改为MouseLeftButtonDown,现在它触发了SelectionChanged事件方法,但是ScrollViewer现在不滚动,导致MouseLeftButtonDown事件方法从未被捕获。叹!     
已邀请:
        将鼠标事件方法更改为:
    private void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        var mousePos = e.GetPosition(objScrollViewer);
        if (mousePos.X <= objScrollViewer.ViewportWidth && mousePos.Y <
            objScrollViewer.ViewportHeight)
        {
            objScrollViewer.Cursor = Cursors.SizeAll;
            lastDragPoint = mousePos;
            Mouse.Capture(objScrollViewer);
        }

        FrameworkElement ctrl = (e.OriginalSource as FrameworkElement);
        if (ctrl != null)
        {
            switch (ctrl.DataContext.GetType().ToString())
            {
                case \"GE.GNF.ACUMEN.Library.SIMULATOR_BUNDLE_NODAL_DATA\":
                    objCoreViewer.SelectedItem = ctrl.DataContext as SIMULATOR_BUNDLE_NODAL_DATA;
                    break;
                case \"GE.GNF.ACUMEN.Library.SIMULATOR_CONTROL_BLADE_NODAL_DATA\":
                    objCoreViewer.SelectedItem = ctrl.DataContext as SIMULATOR_CONTROL_BLADE_NODAL_DATA;
                    break;
                default:
                    break;
            }
        }
    }
    

要回复问题请先登录注册