Keeping the PopupButton popup open

Ribbon for WPF Forum

Posted 6 years ago by Thomas
Version: 17.2.0664
Avatar

Hi,

My WPF Ribbon's PopupButton popup contains a DataGrid and some other controls. Unfortunately the popup quite often gets closed when for whatever reason one of the controls loses focus or is clicked.

I am aware of the Ribbon controls and their StaysOpenOnClick property, but that doesn't help in my case, because my Popup has to contain other controls like for example a DataGrid.

Is there any way to fix this without implementing a lot of hacks?

It would be great, if the popup only gets closed, if the user really clicks somewhere outside the popup and not because of an action inside the popup.

Thanks,

Thomas

Comments (3)

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

Hi Thomas,

Anytime a control "blurs" focus (moves it back to the main focus scope), then that will trigger the PopupButton's popup to close.  WPF Buttons in general by default do blur focus when clicked unless they are coded with some StaysOpenOnClick-like functionality.  It's hard to say what is causing the popup to close in your scenario without a sample project to debug.  If you'd like us to look into it further, please make a new simple sample project that shows it happening and send that to our support address.  Be sure to mention this thread in your email, remove the bin/obj fodlers from the ZIP, and rename the .zip file extension so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 6 years ago by Thomas
Avatar

I think in my case the popup is closed because the DataGrid ItemsSource is changed and therefore the selected DataGrid item loses focus.

It would be great, if the popup button could handle such cases somehow, because currently it can only be used for very simple popups. It's useless for more complicated popups because of all the unwanted auto-closes.

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

Hi Thomas,

Unfortunately we can't really control when an external control loses focus and focus loss does require the popup to be closed, or it would be very difficult to close the popup at all.  I would suggest that if you see your ItemsSource about to change, that you focus the DataGrid itself (if it is focusable... however, note it may auto-focus its first child, which would be bad) or some containing control that is within the Popup prior to the ItemsSource change.  My guess is that if your focus is in a DataGrid child control when DataGrid rebuilds clears its UI in preparation for the new items, core WPF is doing a blur focus.  By focusing something above that level prior to the rebuild, you would avoid the focus blur.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.