How to stop popup from closing when clicked

Ribbon for WPF Forum

Posted 10 years ago by Crile Carvey
Version: 4.5.0480
Avatar
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"
                Margin="5"
                HorizontalAlignment="Left"
                Click="popupChecklist_Click"                                       
                >
                <ActiproShared:PopupButton.PopupContent>
                    <ActiproShared:ResizableContentControl 
                        x:Name="checklistContainer"
                        MinHeight="300"
                        MinWidth="300"
                        Padding="2"
                        BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"
                        BorderThickness="1">

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

Crile

Comments (4)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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 10 years ago by Crile Carvey
Avatar
oops - wrong code

How about this?
               <ribbon:PopupButton 
                                ImageSourceLarge="/Resources/Images/DocumentIcons/QuickParts32.png" 
                                ImageSourceSmall="/Resources/Images/DocumentIcons/QuickParts16.png" 
                                Label="Electrical Violations" 
                                KeyTipAccessText="VE" 
                                StaysOpenOnClick="True"
                                >
                                <shared:ResizableContentControl MinHeight="300" MinWidth="300" Padding="2" BorderThickness="1"  P   >
                                    <StackPanel  >
                                        <Button Content="Okay" />

                                    </StackPanel>
                                </shared:ResizableContentControl>
                            </ribbon:PopupButton>
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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 10 years ago by Crile Carvey
Avatar
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 (v2018.1 build 0675) 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.