[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;
        }

0

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">
                                        <Button.Triggers>
                                            <EventTrigger RoutedEvent="Button.Click">
                                                <EventTrigger.Actions>
                                                    <BeginStoryboard>
                                                        <Storyboard>
                                                            <BooleanAnimationUsingKeyFrames Storyboard.TargetName="CloseThisPopUp" Storyboard.TargetProperty="IsOpen">
                                                                <DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="False" />
                                                            </BooleanAnimationUsingKeyFrames>
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </EventTrigger.Actions>
                                            </EventTrigger>
                                        </Button.Triggers>
                                    </Button>

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

More Related questions