mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-03-20 00:16:35 +08:00
feat: add tooltip. arrow is not supported as there is not indicator of placement on tooltip control itself.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/TextBox.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ToggleButton.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ToggleSwitch.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/Tooltip.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/TreeView.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/UserControl.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/Window.axaml" />
|
||||
|
||||
41
src/Semi.Avalonia/Controls/Tooltip.axaml
Normal file
41
src/Semi.Avalonia/Controls/Tooltip.axaml
Normal file
@@ -0,0 +1,41 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<ControlTheme x:Key="{x:Type ToolTip}" TargetType="ToolTip">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ToolTipForeground}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ToolTipBackground}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ToolTipBorderBrush}" />
|
||||
<Setter Property="BorderThickness" Value="{DynamicResource ToolTipBorderThickness}" />
|
||||
<Setter Property="Padding" Value="{DynamicResource ToolTipPadding}" />
|
||||
<Setter Property="MaxWidth" Value="{DynamicResource ToolTipMaxWidth}" />
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource ToolTipCornerRadius}" />
|
||||
<Setter Property="Opacity" Value="0" />
|
||||
<Setter Property="Transitions">
|
||||
<Transitions>
|
||||
<DoubleTransition Property="Opacity" Duration="0:0:0.1" />
|
||||
</Transitions>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="ToolTip">
|
||||
<Border
|
||||
Name="PART_LayoutRoot"
|
||||
Margin="0,-1,0,0"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
MaxWidth="{TemplateBinding MaxWidth}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
TextBlock.TextWrapping="Wrap" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:open">
|
||||
<Setter Property="Opacity" Value="1" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -23,8 +23,10 @@
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/TextBox.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/ToggleButton.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/ToggleSwitch.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Tooltip.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/TreeView.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Window.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Flyout.axaml" />
|
||||
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
14
src/Semi.Avalonia/Themes/Light/Tooltip.axaml
Normal file
14
src/Semi.Avalonia/Themes/Light/Tooltip.axaml
Normal file
@@ -0,0 +1,14 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="clr-namespace:System;assembly=System.Runtime">
|
||||
<!-- Add Resources Here -->
|
||||
<PathGeometry x:Key="ToolTipTriangleGlyph">M24 0V1C20 1 18.5 2 16.5 4C14.5 6 14 7 12 7C10 7 9.5 6 7.5 4C5.5 2 4 1 0 1V0H24Z</PathGeometry>
|
||||
<SolidColorBrush x:Key="ToolTipBackground" Color="#41464C" />
|
||||
<SolidColorBrush x:Key="ToolTipForeground" Color="White" />
|
||||
<SolidColorBrush x:Key="ToolTipBorderBrush" Color="Transparent" />
|
||||
<CornerRadius x:Key="ToolTipCornerRadius">6</CornerRadius>
|
||||
<Thickness x:Key="ToolTipPadding">12 8</Thickness>
|
||||
<sys:Double x:Key="ToolTipMaxWidth">320</sys:Double>
|
||||
<Thickness x:Key="ToolTipBorderThickness">0</Thickness>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user