feat: add avalonia ToolTip style.

This commit is contained in:
NaBian committed 2025-08-13 21:19:23 +08:00
1 parent 7047087b73
commit 9697e99965
10 files changed
+110 -31

No files matched your search

@@ -60,14 +60,16 @@
Opacity="1"
x:Name="indeterminateMark" />
</Panel>
<ContentPresenter x:Name="contentPresenter"
IsVisible="{Binding $self.Content, Converter={x:Static ObjectConverters.IsNotNull}}"
<ContentPresenter Name="PART_ContentPresenter"
Grid.Column="1"
Focusable="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
IsVisible="{TemplateBinding Content, Converter={x:Static ObjectConverters.IsNotNull}}"
RecognizesAccessKey="True"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
TextElement.Foreground="{TemplateBinding Foreground}" />
</Grid>
</ControlTemplate>
</Setter>
@@ -28,12 +28,6 @@
Height="16"
Margin="4,0,1,0"
Background="Transparent">
<Canvas.Styles>
<Style Selector="ToolTip">
<Setter Property="BorderBrush"
Value="{DynamicResource DangerBrush}" />
</Style>
</Canvas.Styles>
<ToolTip.Tip>
<ItemsControl x:DataType="DataValidationErrors"
ItemsSource="{Binding}" />
@@ -0,0 +1,29 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="{x:Type PopupRoot}"
TargetType="PopupRoot">
<Setter Property="Background"
Value="{x:Null}" />
<Setter Property="TransparencyLevelHint"
Value="Transparent" />
<Setter Property="Foreground"
Value="{DynamicResource PrimaryTextBrush}" />
<Setter Property="Template">
<ControlTemplate>
<LayoutTransformControl LayoutTransform="{TemplateBinding Transform}">
<Panel>
<Border Name="PART_TransparencyFallback"
IsHitTestVisible="False" />
<VisualLayerManager IsPopup="True">
<ContentPresenter Name="PART_ContentPresenter"
Background="{TemplateBinding Background}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
Padding="{TemplateBinding Padding}" />
</VisualLayerManager>
</Panel>
</LayoutTransformControl>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>
@@ -0,0 +1,34 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol">
<ControlTheme x:Key="{x:Type ToolTip}"
TargetType="ToolTip">
<Setter Property="Padding"
Value="{StaticResource DefaultControlPadding}" />
<Setter Property="Background"
Value="{DynamicResource RegionBrush}" />
<Setter Property="BorderBrush"
Value="{DynamicResource BorderBrush}" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="Foreground"
Value="{DynamicResource PrimaryTextBrush}" />
<Setter Property="FontSize"
Value="12" />
<Setter Property="hc:BorderElement.CornerRadius"
Value="{StaticResource DefaultCornerRadius}" />
<Setter Property="Template">
<ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter"
Effect="{StaticResource EffectShadow2}"
Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
BorderBrush="{TemplateBinding BorderBrush}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>
@@ -16,6 +16,8 @@
<MergeResourceInclude Source="/Themes/Basic/Converters.axaml" />
<MergeResourceInclude Source="/Themes/Styles/DataValidationErrors.axaml" />
<MergeResourceInclude Source="/Themes/Styles/PopupRoot.axaml" />
<MergeResourceInclude Source="/Themes/Styles/ToolTip.axaml" />
<MergeResourceInclude Source="/Themes/Styles/TextBlock.axaml" />
<MergeResourceInclude Source="/Themes/Styles/ContentControl.axaml" />
<MergeResourceInclude Source="/Themes/Styles/UserControl.axaml" />