0

マウスがウィンドウの外にあるときにフェードアウトするウィンドウがあります。ボタンをクリックすると(ウィンドウの境界内に)表示されるポップアップを作成しました。しかし、ポップアップの上にマウスを置くと、ウィンドウがフェードアウトしますか?ポップアップを表示しているときにウィンドウがフェードアウトしないようにするにはどうすればよいですか?

フェードアウトコードvoidgridFadeOutStoryBoard_Completed(object sender、EventArgs e){CloseWindow(); }

    private void MainWindow_MouseLeave(object sender, MouseEventArgs e)
    {
        if (this.ResizeMode == System.Windows.ResizeMode.NoResize) // make sure fade out animation won't work when the window is fullscreen
        {
            if (!this.giveFirstTimeMouseLeave)
            {
                // Only start fading out if fully faded in, otherwise you get a flicker effect in the UX because the animation resets the opacity
                if (this.Opacity == 1)
                    gridFadeOutStoryBoard.Begin();
            }
        }
    }

xamlコードをフェードアウトします:

<Storyboard x:Key="gridFadeOutStoryBoard">
        <DoubleAnimation Storyboard.TargetName="MyWin" BeginTime="0:0:0.5"
            Storyboard.TargetProperty="Opacity" From="1.00" To="0.75" AutoReverse="False" Duration="0:0:0.3" />
    </Storyboard>

ポップアップxamlコード:

<Popup Name="FilterPopup" Width="200" Height="150" HorizontalAlignment="Left" Margin="0,36,0,0" IsEnabled="True" IsOpen="False">
            <Border BorderBrush="White" BorderThickness="3">
                <StackPanel Background="#FF333333" VerticalAlignment="Center" Height="200">
                    <StackPanel>
                        <Grid Margin="0,40,0,20">
                            <Grid.RowDefinitions>
                                <RowDefinition Height=" 30"></RowDefinition>
                                <RowDefinition Height="30"></RowDefinition>
                                <RowDefinition Height="30"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100"></ColumnDefinition>
                                <ColumnDefinition Width="100"></ColumnDefinition>
                                <ColumnDefinition Width="100"></ColumnDefinition>
                            </Grid.ColumnDefinitions>

                            <Label Name="lblPasswordReprint" Content="Password:" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                            <TextBox Name="txtPasswordReprint" Width=" 90" Height="20" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" IsEnabled="True"/>

                            <Label Name="lblUserName" Content=" UserName:" HorizontalAlignment="Right" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" />
                            <TextBox Name="txtUserNameReprint" Width=" 90" Height=" 20" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left"/>

                            <Button Content="Reset" Width="70" Height="30" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" />
                            <Button Content="Save" Width="70" Height="30" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" />
                        </Grid>
                    </StackPanel>
                </StackPanel>
            </Border>
        </Popup>

よろしくお願いします、ディン。

4

1 に答える 1

2

あなたの中にあなたMainWindow_MouseLeaveはFilterPopup.IsMouseOverの追加のチェックを追加することができます-それは本当ですそしてアニメーションをスキップします

于 2012-06-30T23:22:38.940 に答える