Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Allow only one Popup Control instance at a time.

$
0
0

I have a ListView and each item holds a button, in this case a Toggle Button.

If the user clicks a button, a Popup control instance opens with data that is bound to and loaded from a ViewModel.

If the user clicks the same button again, the Popup control closes.

The problem starts to show up when the user doesn't close the first instance of a Popup and clicks on another button. In this case, the user could go on and on by clicking many buttons that trigger multiple instances of Popup control.

How to stop this behavior and allow only one popup instance at a time in XAML.

<ToggleButton Name="tButton"
                                         DataContext="{Binding DataContext, ElementName=Root}"
                                        Command="{Binding DataCommand}"
                                        CommandParameter="{Binding Text, ElementName=E1}"><Grid><Popup AllowsTransparency="True"
                                                   Placement="Bottom"
                                                IsOpen="{Binding Path=IsChecked, ElementName=tButton, Mode=OneWay}">


Viewing all articles
Browse latest Browse all 18858