PopupButton,PropertyGrid,PropertyEditor.Popup won't autoclos

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 14 years ago by jeff jarrell
Version: 10.1.0520
Platform: .NET 3.5
Environment: Windows XP (32-bit)
Avatar
We have developed a number of PropertyGridEditors that use the popupButton.PopupContent. This works well when the propertyGrid is used normally. When these PropertyGridEditors are used from a normal property grid, they autoclose nicely as focus moves away or user clicks to something else.

If we put the PropertyGrid inside a PopupButton.PopupContent then the PropertyGridEditors.Popup windows don't close automatically. They stay open until they are closed explicity.

We do this because we are using PopupButton like a VS SmartTag. From there we popup the PropertyGrid with just a few properties. Conceptually, it looks good but the autoclose makes it hard to use.

I do have a sample project that illustrates the problem.

Ideas?

Thanks.
jeff

Comments (4)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jeff,

It's hard to say without seeing it in action. If you can send the sample project to our support address, then we can take a closer look. Be sure to rename the zip file's extension or remove any exe/dll files.

When opening a popup, the PopupButton will capture the mouse and then it will close when the capture is lost (unless one of it's popup's children has received focus). I'm not sure it's related, but chances are it has to do with some quirks with the focus/mouse capture.


Actipro Software Support

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Sorry, just saw you already sent the sample.


Actipro Software Support

Posted 14 years ago by jeff jarrell
Avatar
Any thoughts on this?
thanks.
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jeff,

We responded to the support ticket you created, but I've included the response here.

This appears to be how the WPF Popup was designed to work. If you look in the Popup.EstablishPopupCapture() method, you can see that they explicitly check that no other element has the mouse capture currently (i.e. Mouse.Captured == null). I was able to duplicate this using only a ToggleButton, TextBox, and Popup. Sorry, but off the top of my head, I'm not sure there's a way to force this work as you'd expect.
<Window.Resources>  
    <Style x:Key="ToggleButtonStyle" TargetType="ToggleButton">   
        <Setter Property="Template">   
            <Setter.Value>  
                <ControlTemplate TargetType="ToggleButton">   
  
                    <Grid Name="Placement" SnapsToDevicePixels="true">   
                        <Grid.ColumnDefinitions>  
                            <ColumnDefinition Width="*" />  
                            <ColumnDefinition Width="Auto" />  
                        </Grid.ColumnDefinitions>  
  
                        <Popup Name="PART_Popup" Grid.ColumnSpan="2" AllowsTransparency="true" Placement="Bottom"  
                               StaysOpen="False"  
                                IsOpen="{Binding Path=IsChecked, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"  
                                PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">   
                            <Border x:Name="DropDownBorder" BorderThickness="1"  
                                    BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}"  
                                    Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">   
                                <ScrollViewer>  
                                    <ContentPresenter />  
                                </ScrollViewer>  
                            </Border>  
                        </Popup>  
  
                        <Border x:Name="Border" Grid.ColumnSpan="2" BorderThickness="{TemplateBinding BorderThickness}"  
                                BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">   
                            <StackPanel>  
                                <TextBlock Text="Click Here To Open" />  
                                <TextBox Text="Click Here To Close" />  
                            </StackPanel>  
                        </Border>  
                    </Grid>  
  
                </ControlTemplate>  
  
  
            </Setter.Value>  
        </Setter>  
    </Style>  
</Window.Resources>  
  
<ToggleButton Style="{StaticResource ToggleButtonStyle}">   
    <ToggleButton Style="{StaticResource ToggleButtonStyle}">   
        <TextBox Text="Content" />  
    </ToggleButton>  
</ToggleButton>


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.