|
| 1 | +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 2 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 3 | + xmlns:local="clr-namespace:Fischless.Relauncher.Views.Controls"> |
| 4 | + <!-- Converter registration --> |
| 5 | + <local:TooltipCenterOffsetConverter x:Key="TooltipCenterOffsetConverter" /> |
| 6 | + <Style x:Key="BalloonToolTip" TargetType="ToolTip"> |
| 7 | + <!-- Basic properties --> |
| 8 | + <Setter Property="OverridesDefaultStyle" Value="True" /> |
| 9 | + <Setter Property="HasDropShadow" Value="False" /> |
| 10 | + <Setter Property="Placement" Value="Bottom" /> |
| 11 | + <Setter Property="ToolTipService.ShowDuration" Value="0" /> |
| 12 | + <Setter Property="ToolTipService.HorizontalOffset" Value="{Binding ActualWidth, RelativeSource={RelativeSource Self}, Converter={StaticResource TooltipCenterOffsetConverter}}" /> |
| 13 | + <Setter Property="ToolTipService.VerticalOffset" Value="4" /> |
| 14 | + <Setter Property="ToolTipService.InitialShowDelay" Value="0" /> |
| 15 | + <Setter Property="ToolTipService.BetweenShowDelay" Value="0" /> |
| 16 | + <Setter Property="ToolTipService.ShowDuration" Value="6000" /> |
| 17 | + <Setter Property="ToolTipService.PlacementTarget" Value="{Binding RelativeSource={RelativeSource Self}}" /> |
| 18 | + <Setter Property="Template"> |
| 19 | + <Setter.Value> |
| 20 | + <ControlTemplate TargetType="ToolTip"> |
| 21 | + <!-- Root container with scale transform for animation --> |
| 22 | + <Grid RenderTransformOrigin="0.5,0"> |
| 23 | + <Grid.RenderTransform> |
| 24 | + <ScaleTransform x:Name="scale" ScaleX="0.8" ScaleY="0.8" /> |
| 25 | + </Grid.RenderTransform> |
| 26 | + <StackPanel> |
| 27 | + <!-- Arrow --> |
| 28 | + <Path HorizontalAlignment="Center" |
| 29 | + Data="M 0 6 L 6 0 L 12 6 Z" |
| 30 | + Fill="#F2F2F2" |
| 31 | + Stroke="#CCC" |
| 32 | + StrokeThickness="0.5" /> |
| 33 | + <!-- Content box --> |
| 34 | + <Border Padding="11,5" |
| 35 | + Background="#F2F2F2" |
| 36 | + BorderBrush="#CCC" |
| 37 | + BorderThickness="0.5" |
| 38 | + CornerRadius="4"> |
| 39 | + <TextBlock FontFamily="Microsoft Yahei UI" |
| 40 | + FontSize="14" |
| 41 | + Foreground="#36373A" |
| 42 | + Text="{TemplateBinding Content}" /> |
| 43 | + </Border> |
| 44 | + </StackPanel> |
| 45 | + </Grid> |
| 46 | + <!-- Animation trigger --> |
| 47 | + <ControlTemplate.Triggers> |
| 48 | + <!-- When tooltip opens, play scale + fade animation --> |
| 49 | + <EventTrigger RoutedEvent="ToolTip.Opened"> |
| 50 | + <BeginStoryboard> |
| 51 | + <Storyboard> |
| 52 | + <!-- Scale animation --> |
| 53 | + <DoubleAnimation Storyboard.TargetName="scale" |
| 54 | + Storyboard.TargetProperty="ScaleX" |
| 55 | + From="0.8" |
| 56 | + To="1.0" |
| 57 | + Duration="0:0:0.15"> |
| 58 | + <DoubleAnimation.EasingFunction> |
| 59 | + <QuadraticEase EasingMode="EaseOut" /> |
| 60 | + </DoubleAnimation.EasingFunction> |
| 61 | + </DoubleAnimation> |
| 62 | + <DoubleAnimation Storyboard.TargetName="scale" |
| 63 | + Storyboard.TargetProperty="ScaleY" |
| 64 | + From="0.8" |
| 65 | + To="1.0" |
| 66 | + Duration="0:0:0.15"> |
| 67 | + <DoubleAnimation.EasingFunction> |
| 68 | + <QuadraticEase EasingMode="EaseOut" /> |
| 69 | + </DoubleAnimation.EasingFunction> |
| 70 | + </DoubleAnimation> |
| 71 | + <!-- Fade-in animation --> |
| 72 | + <DoubleAnimation Storyboard.TargetProperty="Opacity" |
| 73 | + From="0" |
| 74 | + To="1" |
| 75 | + Duration="0:0:0.15" /> |
| 76 | + </Storyboard> |
| 77 | + </BeginStoryboard> |
| 78 | + </EventTrigger> |
| 79 | + </ControlTemplate.Triggers> |
| 80 | + </ControlTemplate> |
| 81 | + </Setter.Value> |
| 82 | + </Setter> |
| 83 | + </Style> |
| 84 | +</ResourceDictionary> |
0 commit comments