WPF“工具提示”弹出窗口闪烁

长话短说:我有一个窗口,在ListBox中显示一堆图表.当mouseOver图表(使用LineSeries)时,有一行跟在dataPoints之后(捕捉到dataPoint位置).在那条线附近,我正在展示一个由弹出窗口提供的工具提示,该弹出窗口显示有关这些dataPoints的信息.

到现在为止还挺好.问题是当我尝试将鼠标移到工具提示上时,弹出窗口开始闪烁(就像在打开/关闭循环中一样).我已经设置了弹出窗口和孩子IsHitTestVisible =“False”.

作为一个临时解决方案,弹出窗口“走出”游标的方式如下:

……但很难“理解”.

现在出现了一个问题:出了什么问题?当鼠标悬停在弹出窗口上时,为什么弹出窗口会开始闪烁.

任何反馈欢迎

PS.工具提示XAML(它是在代码中创建的,但在这里它是):

图表的datacontext是绑定到类的数据,也有一些图表的事件是通过icommands实现的.弹出窗口是在该类的构造函数中创建的,

ppchart = New Popup() With {.AllowsTransparency = True, .IsHitTestVisible = False,.StaysOpen = True}

…在MouseMoveCommand中创建弹出窗口的子节点:

Dim ppCont As XElement = <Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                                     xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" IsHitTestVisible="False" VerticalAlignment="Top">
                                     <Grid.RowDefinitions>
                                         <RowDefinition Height="Auto"/>
                                         <RowDefinition Height="Auto"/>
                                     </Grid.RowDefinitions>
                                     <Rectangle Opacity="0.5" Grid.RowSpan="2" IsHitTestVisible="False" StrokeThickness="0" RadiusX="2" RadiusY="2" Fill="#FFBABABA"/>
                                     <TextBlock Text="{Binding Over, StringFormat=HH:mm}" FontSize="9" TextAlignment="Center" FontFamily="Segoe UI" IsHitTestVisible="False" Margin="1"/>
                                     <ListBox x:Name="listBox" ItemsSource="{Binding Points}" Background="{x:Null}" BorderBrush="{x:Null}" FontSize="8" Margin="1,0,1,1" Grid.Row="1" IsHitTestVisible="False" IsTextSearchEnabled="False" HorizontalAlignment="Stretch">
                                         <ListBox.ItemContainerStyle>
                                             <Style TargetType="{x:Type ListBoxItem}">
                                                 <Setter Property="Background" Value="Transparent"/>
                                                 <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                                                 <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                                                 <Setter Property="Padding" Value="0"/>
                                                 <Setter Property="IsHitTestVisible" Value="False"/>
                                             </Style>
                                         </ListBox.ItemContainerStyle>
                                         <ListBox.ItemTemplate>
                                             <DataTemplate>
                                                 <Grid IsHitTestVisible="False">
                                                     <Grid.ColumnDefinitions>
                                                         <ColumnDefinition Width="Auto"/>
                                                         <ColumnDefinition Width="Auto"/>
                                                         <ColumnDefinition Width="Auto"/>
                                                     </Grid.ColumnDefinitions>
                                                     <Rectangle Fill="{Binding Culoare}" Width="3" HorizontalAlignment="Left" Margin="1" IsHitTestVisible="False"/>
                                                     <TextBlock Text="{Binding Operation}" HorizontalAlignment="Stretch" IsHitTestVisible="False" Grid.ColumnSpan="1" Grid.Column="1"/>
                                                     <TextBlock Text="{Binding points.Value}" HorizontalAlignment="Stretch" Grid.Column="2" TextAlignment="Right" IsHitTestVisible="False"/>
                                                 </Grid>
                                             </DataTemplate>
                                         </ListBox.ItemTemplate>
                                     </ListBox>
                                 </Grid>

        ppchart.Effect = New Effects.DropShadowEffect() With {.Opacity = 0.5, .BlurRadius = 5, .Direction = 80, .Color = Colors.Black}
        ppchart.Child = CType(XamlReader.Load(New XmlTextReader(New StringReader(ppCont.ToString))), UIElement)

reedited:这是它的样子

最佳答案 阅读评论后,我相信你正在使用不正确的事件;每次弹出窗口显示/隐藏或闪烁时,都会不断触发MouseMove事件.

您想使用MouseEnter和MouseLeave事件.

点赞