長話短說:我有一個窗口,在ListBox中顯示一堆圖表。當mouseOver圖表(使用LineSeries)時,會有一行跟隨dataPoints(捕捉到dataPoint位置)。在該行附近,我展示了一個由彈出窗口提供的工具提示,該窗口顯示有關這些數據點的信息。WPF「工具提示」彈出窗口閃爍
到目前爲止這麼好。問題是當我嘗試將鼠標移動到工具提示上時,彈出窗口開始閃爍(就像它在打開/關閉循環中一樣)。我已經設置了彈出窗口和兒童IsHitTestVisible="False"
。
作爲一個臨時的解決方案在彈出的「雲」出來的遊標方式喜歡這裏:
...但幾乎沒有「可以理解的」。
現在出現了這樣一個問題:怎麼了?爲什麼鼠標懸停時彈出菜單開始閃爍。
歡迎任何反饋意見
PS。工具提示XAML(它是在代碼中創建的,但是在這裏):
圖表的datacontext是綁定到類的數據,也有一些圖表的事件是通過命令實現的。彈出窗口是在類的構造函數創建,
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)
重新編輯:這是怎麼看起來像
可以發佈用於工具提示的XAML嗎? – Dennis 2012-04-07 12:22:38
你爲什麼要設置IsHitTestVisible?你沒有試過嗎? – 2012-04-07 12:38:42
我第一次嘗試沒有設置它,它也閃爍...... – 2012-04-07 12:53:29