Skip to content

In wpf with vb, there is no closing of a popup opened from another popup with the Staysopen property set to true. #11824

Description

@Perpete
Image

Description

In WPF with VB, I have a main window representing a toolbar.

A button in the main window opens a popup with the StaysOpen property set to True.

From a button in the popup, I open a second popup with StaysOpen set to False.

After the first time the second popup opens, it closes correctly.

After subsequent openings, this popup no longer closes when clicked outside its designated area.

Here is the test program.
PopupTest.zip

Reproduction Steps

"<Window x:Class="MainWindow"

     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     mc:Ignorable="d"
     KeyboardNavigation.TabNavigation="None"
     SizeToContent="WidthAndHeight"
     Title="MainWindow"  WindowStyle="None" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" AllowsTransparency="True" Background="Transparent" Topmost="True">
<Grid>
    <Border Background="#FF3B333B" CornerRadius="10" BorderBrush="#FF989898" BorderThickness="1" Height="40">
        <StackPanel Orientation="Horizontal">
            <Button x:Name="btnOpenPopup1" Height="32" Width="100" Content="Open Popup 1"/>
            <Border Width="1" Height="32" Background="White" VerticalAlignment="Center" Margin="2,0" />
            <Button x:Name="btnClosePopup" Height="32" Width="100" Margin="2,0" Content="Close Popup"/>
            <Border Width="1" Height="32" Background="White" VerticalAlignment="Center" Margin="2,0" />
            <Button x:Name="btnClose" Height="32" Width="100" Margin="2,0" Content="Close X"/>
        </StackPanel>
    </Border>

    <Popup x:Name="Popup1" IsOpen="False" Placement="Bottom" AllowsTransparency="True" VerticalOffset="10" StaysOpen="True">
        <Border Background="#FF3B333B" CornerRadius="10" BorderBrush="#FF989898" BorderThickness="1" Height="40">
            <StackPanel Orientation="Horizontal">
                <Label Content="Popup 1 - StaysOpen=True" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                <Button x:Name="btnOpenPopup2" Height="32" Width="100" Content="Open Popup 2"/>   
            </StackPanel>
        </Border>
    </Popup>
    
    <Popup x:Name="Popup2" IsOpen="False" Placement="Bottom" StaysOpen="False">
        <Border BorderThickness="1" BorderBrush="#FF909090" Background="#FF4B434B">
            <Grid>
                <Label Content="Popup 2 - StaysOpen=False" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
            </Grid>
        </Border>
    </Popup>

</Grid>

`Class MainWindow
Private Sub btnOpenPopup1_Click(sender As Object, e As RoutedEventArgs) Handles btnOpenPopup1.Click

    'Affiche le popup 1
    Popup1.PlacementTarget = btnOpenPopup1
    Popup1.IsOpen = True
End Sub

Private Sub btnOpenPopup2_Click(sender As Object, e As RoutedEventArgs) Handles btnOpenPopup2.Click

    'Affiche le popup 2
    Popup2.PlacementTarget = btnOpenPopup2
    Popup2.IsOpen = True
End Sub

Private Sub btnClose_Click(sender As Object, e As RoutedEventArgs) Handles btnClose.Click

    'Ferme la fenêtre principale
    Close()
End Sub

Private Sub btnClosePopup_Click(sender As Object, e As RoutedEventArgs) Handles btnClosePopup.Click

    'Ferme les popups
    Popup1.IsOpen = False
    Popup2.IsOpen = False
End Sub

End Class`

Expected behavior

The ability to always close the popup.

Actual behavior

see description.

Regression?

No response

Known Workarounds

Not found.

Impact

No response

Configuration

.net 10

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugProduct bug (most likely)Cost:MWork that requires one engineer up to 2 weeksPriority:2Work that is important, but not critical for the release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions