【发布时间】:2012-06-30 20:19:23
【问题描述】:
当鼠标离开窗口时,我有一个淡出的窗口。 我创建了一个弹出窗口,当我单击按钮时会显示(在窗口边界内)。 但是 - 当我将鼠标悬停在弹出窗口上时 - 我的窗口消失了? 当我在弹出窗口时,我该怎么做才能使窗口不会淡出?
淡出代码 void gridFadeOutStoryBoard_Completed(对象发送者,EventArgs e) { 关闭窗口(); }
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>
提前致谢, 叮..
【问题讨论】:
-
弹出窗口本身就是另一个窗口,这就是问题所在。
-
这就是我的想法..我需要弹出窗口(因为它浮动)..我的问题没有解决方案吗?