In WPF When we clicked on Toggle button then popup open properly but when we clicked on outside of popup then popup is auto closed. how to prevent this.
when we clicked on outside of popup then the popup should not be closed.
Code:
<ToggleButton Name="TglBtn" Content="Document" />
<Popup IsOpen="{Binding IsChecked, ElementName=TglBtn}" StaysOpen="False" PlacementTarget="{Binding ElementName=popupDocshow}" x:Name="pop1">
<TextBlock Text="Documents" Background="Blue"/>
</Popup>
PopupTest.StaysOpen = true this is what you are missing.
<Popup x:Name="PopupTest" AllowsTransparency="True">
<Viewbox VerticalAlignment="Top">
<TextBlock Text="Wow, that was easy!"/>
</Viewbox>
</Popup>
private void Button_Click(object sender, RoutedEventArgs e)
{
PopupTest.Placement = System.Windows.Controls.Primitives.PlacementMode.Mouse;
PopupTest.StaysOpen = true;
PopupTest.Height = 1000;
PopupTest.Width = 500;
PopupTest.IsOpen = true;
}
this is the popup i checked on
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With