[ACCEPTED]-How to close WPF popup window?-wpf

Accepted answer
Score: 11

You can close the popup by setting the IsOpen property 1 to false.

Score: 5

you can try with

private void btnClosePopup_Click(object sender, RoutedEventArgs e)
            popup.IsOpen = false;


Score: 0

If you would like to solve it in the XAML 4 code, here is a working solution (put the 3 Close button inside the popup):

    <Button Name="CloseThisPopUp" VerticalAlignment="Top" HorizontalAlignment="Right" Content="X">
                                            <EventTrigger RoutedEvent="Button.Click">
                                                            <BooleanAnimationUsingKeyFrames Storyboard.TargetName="CloseThisPopUp" Storyboard.TargetProperty="IsOpen">
                                                                <DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="False" />

You can also 2 use this code to open a popup, just change 1 the IsOpen property to "True".

More Related questions