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

@@ -15,7 +15,6 @@
[ "TextBlock", "TextBlockDemo", "Brush.TextBlock", "", "" ],
[ "TextBox", "TextBoxDemo", "Brush.TextBox", "", "" ],
[ "ComboBox", "NativeComboBoxDemo", "Brush.ComboBox", "", "" ],
[ "PasswordBox", "NativePasswordBoxDemo", "Brush.PasswordBox", "", "" ],
[ "Expander", "ExpanderDemo", "Brush.Expander", "", "" ],
[ "ProgressBar", "NativeProgressBarDemo", "Brush.ProgressBar", "", "" ],
[ "Calendar", "CalendarDemo", "Brush.Calendar", "", "" ],
@@ -55,7 +54,6 @@
[ "ComboBox", "ComboBoxDemo", "Brush.ComboBox", "", "DataEntry" ],
[ "CheckComboBox", "CheckComboBoxDemo", "Brush.CheckBoxList", "", "DataEntry" ],
[ "AutoCompleteTextBox", "AutoCompleteTextBoxDemo", "Brush.AutoComplete", "1", "DataEntry" ],
[ "PasswordBox", "PasswordBoxDemo", "Brush.PasswordBox", "", "DataEntry" ],
[ "PinBox", "PinBoxDemo", "Brush.Ellipsis", "", "DataEntry" ],
[ "DatePicker", "DatePickerDemo", "Brush.DateTimePicker", "", "DataEntry" ],
[ "Clock", "ClockDemo", "Brush.Time", "", "DataEntry" ],
@@ -53,6 +53,7 @@
</StackPanel>
<StackPanel>
<TextBox Text="This is the content"
PasswordChar="●"
Theme="{StaticResource TextBox.Small}" />
<TextBox Text="This is the content"
Margin="0,16,0,0"
@@ -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" />
@@ -11458,16 +11458,18 @@
</Style.Triggers>
</Style>
<Style x:Key="ToolTipBaseStyle" TargetType="ToolTip">
<Setter Property="Padding" Value="0,6" />
<Setter Property="Background" Value="White" />
<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="2" />
<Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToolTip">
<Border Effect="{StaticResource EffectShadow2}" Margin="8" Background="{DynamicResource RegionBrush}" Padding="{TemplateBinding Padding}" BorderThickness="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{DynamicResource BorderBrush}">
<ContentPresenter Margin="10,0" />
<Border Effect="{StaticResource EffectShadow2}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" BorderThickness="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
@@ -2,17 +2,32 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="clr-namespace:HandyControl.Controls">
<Style x:Key="ToolTipBaseStyle" TargetType="ToolTip">
<Setter Property="Padding" Value="0,6"/>
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="hc:BorderElement.CornerRadius" Value="2"/>
<Style x:Key="ToolTipBaseStyle"
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">
<Setter.Value>
<ControlTemplate TargetType="ToolTip">
<Border Effect="{StaticResource EffectShadow2}" Margin="8" Background="{DynamicResource RegionBrush}" Padding="{TemplateBinding Padding}" BorderThickness="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{DynamicResource BorderBrush}">
<ContentPresenter Margin="10,0"/>
<Border Effect="{StaticResource EffectShadow2}"
Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}"
BorderThickness="1"
CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}"
BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
@@ -11577,16 +11577,18 @@
</Style.Triggers>
</Style>
<Style x:Key="ToolTipBaseStyle" TargetType="ToolTip">
<Setter Property="Padding" Value="0,6" />
<Setter Property="Background" Value="White" />
<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="2" />
<Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToolTip">
<Border Effect="{StaticResource EffectShadow2}" Margin="8" Background="{DynamicResource RegionBrush}" Padding="{TemplateBinding Padding}" BorderThickness="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{DynamicResource BorderBrush}">
<ContentPresenter Margin="10,0" />
<Border Effect="{StaticResource EffectShadow2}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" BorderThickness="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>