I have a window that fades out when the mouse is out of the Window. I have created a popup that shows (inside of the window boundaries) when I click a button. But - when I mouse over the popup - my window fades out? What can i do so the window won't fade out when I am on the popup?
Fade out code void gridFadeOutStoryBoard_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();
}
}
}
Fade out xaml code:
<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>
Popup xaml code:
<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>
Thanks in advanced, Din..