How to stop popup from closing when clicked

Ribbon for WPF Forum

Posted 15 years ago by Crile Carvey
Version: 4.5.0480
I have a user control inside a RibbonPopup like this:

     <ActiproShared:PopupButton Grid.Row="0" Grid.Column="2" x:Name="popupChecklist"
                Content="Common violation checklist"  Visibility="Hidden"
                        BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"

                        <SafireControls:InspectionChecklistControl x:Name="PopupChecklistControl" Height="auto" />
Whenever a user clicks my control, the popup closes. How can I control this?


Comments (4)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Crile,

You said that you are using a Ribbon Popup, but the code you posted looks like it's using the PopupButton from the Shared library.

Assuming you are using the PopupButton from the Shared Library, then internally we are just using a Popup (System.Windows.Controls.Primitives). I believe it closes up if the mouse capture is lost, but there a definitely some special circumstances. In the QuickStart for the PopupButton, we show a TextBox in the popup which you can click in without the popup closing.

I believe it probably has to do with the focus, but if you could send over a sample project then I could determine if that is correct.

Additionally, we could add a StaysOpen property to the PopupButton which would keep the popup open until it's explicitly close (by clicking the drop-down button or IsPopupOpen is set to false). But I'm not sure this is what you are looking for.

Actipro Software Support

Posted 15 years ago by Crile Carvey
oops - wrong code

How about this?
                                Label="Electrical Violations" 
                                <shared:ResizableContentControl MinHeight="300" MinWidth="300" Padding="2" BorderThickness="1"  P   >
                                    <StackPanel  >
                                        <Button Content="Okay" />

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Depending on your situation, you may be able to set Focusable to false on your button. But again, it depends on where you are using the PopupButton (e.g. in a menu, in a group, etc.).

Also, I believe that the standard WPF Button via Microsoft's OnLostMouseCapture code will restore focus to the main focus scope when the button is used outside of the main focus scope, as is the case when in a Ribbon. Thus the popup closes when the button is clicked.

Actipro Software Support

Posted 15 years ago by Crile Carvey
thanks - I found a workaround by declaring a WPF popup outside the ribbon XAML, rather than using ribbon:Popup. It works, although I would have preferred to have popup declared inside the ribbon - the code would then "read" better to a newcomer.
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.