Posted 2 years ago by John Lutz
Version: 18.1.0670

I have a combobox-like control consisting of a Popup that shows a TreeView.   StaysOpen is set to false.    I'm working on a bug where the property page containing the control is scrollable.   While the Popup is popped up, using the mouse wheel over the property page scrolls the page behind the popup.   

How would I get the wheel to

1) Close the popup when it's not over the popup.

2) Work on the TreeView when it's over the popup.

Comments (4)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA

Hi John,

Are any of our controls used in this setup or is this more of a general WPF question?

I would think that a TreeView would capture the mouse wheel scroll if the mouse was over the TreeView at the time.  If that control didn't handle the mouse wheel event, I could see it bubbling up to the ScrollViewer that is probably in your property page.  Determining when the mouse wheel event fires in the property page would be tougher though since the nested ScrollViewer control likely handles it.  It might need you to attach to the PreviewMouseWheel event.

Actipro Software Support

Posted 1 year ago by John Lutz

I'm using this control...


Posted 1 year ago by John Lutz
 <Border BorderThickness="1" BorderBrush="{x:Static SystemColors.ActiveBorderBrush}">
  <ScrollViewer VerticalScrollBarVisibility="Auto" CanContentScroll="True" HorizontalScrollBarVisibility="Disabled">
   <MyTreeView x:Name="_popup" PreviewMouseLeftButtonUp="Popup_OnMouseLeftButtonUp" PreviewLostKeyboardFocus="Popup_OnLostKeyboardFocus" PreviewKeyDown="Popup_OnKeyDown"/>

[Modified 1 year ago]

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA

Hi John,

The WPF TreeView control has its own ScrollViewer within its control template so you shouldn't need another ScrollViewer surrounding it.  You can use various ScrollViewer attached properties right on TreeView to set properties like VerticalScrollBarVisibility.

My recommendation would be to handle the mouse wheel event appropriately in your custom MyTreeView control.  Setting e.Handled should prevent it from bubbling up past that into any ScrollViewers that contain the MyTreeView (and thus PopupButton).  As for closing the popup, you'd have to probably handle the ScrollChanged event of the ScrollViewer that contains the PopupButton and in that, set the PopupButton.IsPopupOpen property to false if it's true.

Or if I'm not understanding the problem properly, please provide some more detail.  Thanks!

Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.