0

我想在我的 silverlight 应用程序中关闭鼠标移出弹出窗口。我怎样才能做到这一点?

另外,如果可能的话,我的要求是在鼠标移出一些延迟后关闭弹出窗口,这意味着当用户鼠标移出时,经过一些延迟,弹出窗口应该关闭。

谢谢,帕拉克


我正在尝试处理 popup 的 mouseleave 事件,但我不知道为什么它没有被调用。你能给我一个[Dispatchertimer]的例子吗?

这是 .xaml 代码:

<Grid x:Name="LayoutRoot" Background="Transparent">

    <StackPanel HorizontalAlignment="Right" VerticalAlignment="Center"  Orientation="Horizontal">

        <telerik:RadButton  x:Name="rbtnSave" Content="Save" Click="rbtnSave_Click" ToolTipService.ToolTip="Save Changes">

        </telerik:RadButton>

        <Border x:Name="borderSaveChanges" BorderThickness="1,0,0,0" BorderBrush="{StaticResource SCBCxWhite}" Width="2" Height="20"></Border>

        <telerik:RadButton  x:Name="rbtnMenu" Background="{StaticResource SCBCxBlue}" Click="rbtnMenu_Click"
            Content="Menu" ToolTipService.ToolTip="Configurations Settings" >

        </telerik:RadButton>


        <Popup x:Name="PopUpMenu" FlowDirection="LeftToRight" 
           HorizontalAlignment="Left" VerticalAlignment="Center">

            <Grid x:Name="popGrid" Background="{StaticResource PopUpBackgroundImg}" Margin="-70,5,20,20" Height="100" Width="200" HorizontalAlignment="Left" VerticalAlignment="Center" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="15"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="5"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <telerik:RadButton x:Name="imgClose" Click="imgClose_Click" HorizontalAlignment="Right"
                                   VerticalAlignment="Top" Grid.Row="1" Margin="0,8,15,5" Style="{StaticResource RadButtonEllipseClose}"/>
                <ListBox Style="{StaticResource WindowControlListBox}" Background="Transparent"  Height="100" Width="200" BorderThickness="0" Grid.Row="2">
                    <ListBoxItem Style="{StaticResource WindowControlListBoxItem}" Content="Configuration"></ListBoxItem>
                    <ListBoxItem Style="{StaticResource WindowControlListBoxItem}" Content="Settings"></ListBoxItem>
                </ListBox>
            </Grid>

        </Popup>

        <Border x:Name="borderMenu" BorderThickness="1,0,0,0" BorderBrush="{StaticResource SCBCxWhite}" Width="2" Height="20"></Border>

        <telerik:RadButton  x:Name="rbtnInformation" Click="rbtnInformation_Click"   Content="Help" ToolTipService.ToolTip="Help">

        </telerik:RadButton>

        <Border x:Name="borderInfo" BorderThickness="1,0,0,0" BorderBrush="{StaticResource SCBCxWhite}" Width="2" Height="20"></Border>
        <telerik:RadButton  x:Name="rbtnMinimize" Click="rbtnMinimize_Click"  Content="Dock" ToolTipService.ToolTip="Minimize">

        </telerik:RadButton>

        <Border x:Name="borderMinimize" BorderThickness="1,0,0,0" BorderBrush="{StaticResource SCBCxWhite}" Width="2" Height="20"></Border>
        <telerik:RadButton  x:Name="rbtnClose" Click="rbtnClose_Click"  Content="Close" ToolTipService.ToolTip="Close" >

        </telerik:RadButton>

    </StackPanel>

</Grid>
4

1 回答 1

0

您可以处理MouseLeave事件以确定何时发生鼠标移出,然后通过PopUp.IsOpen关闭弹出窗口。您可以通过DispatcherTimer.

于 2012-07-30T08:56:51.400 回答