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", "", "" ], [ "TextBlock", "TextBlockDemo", "Brush.TextBlock", "", "" ],
[ "TextBox", "TextBoxDemo", "Brush.TextBox", "", "" ], [ "TextBox", "TextBoxDemo", "Brush.TextBox", "", "" ],
[ "ComboBox", "NativeComboBoxDemo", "Brush.ComboBox", "", "" ], [ "ComboBox", "NativeComboBoxDemo", "Brush.ComboBox", "", "" ],
[ "PasswordBox", "NativePasswordBoxDemo", "Brush.PasswordBox", "", "" ],
[ "Expander", "ExpanderDemo", "Brush.Expander", "", "" ], [ "Expander", "ExpanderDemo", "Brush.Expander", "", "" ],
[ "ProgressBar", "NativeProgressBarDemo", "Brush.ProgressBar", "", "" ], [ "ProgressBar", "NativeProgressBarDemo", "Brush.ProgressBar", "", "" ],
[ "Calendar", "CalendarDemo", "Brush.Calendar", "", "" ], [ "Calendar", "CalendarDemo", "Brush.Calendar", "", "" ],
@@ -55,7 +54,6 @@
[ "ComboBox", "ComboBoxDemo", "Brush.ComboBox", "", "DataEntry" ], [ "ComboBox", "ComboBoxDemo", "Brush.ComboBox", "", "DataEntry" ],
[ "CheckComboBox", "CheckComboBoxDemo", "Brush.CheckBoxList", "", "DataEntry" ], [ "CheckComboBox", "CheckComboBoxDemo", "Brush.CheckBoxList", "", "DataEntry" ],
[ "AutoCompleteTextBox", "AutoCompleteTextBoxDemo", "Brush.AutoComplete", "1", "DataEntry" ], [ "AutoCompleteTextBox", "AutoCompleteTextBoxDemo", "Brush.AutoComplete", "1", "DataEntry" ],
[ "PasswordBox", "PasswordBoxDemo", "Brush.PasswordBox", "", "DataEntry" ],
[ "PinBox", "PinBoxDemo", "Brush.Ellipsis", "", "DataEntry" ], [ "PinBox", "PinBoxDemo", "Brush.Ellipsis", "", "DataEntry" ],
[ "DatePicker", "DatePickerDemo", "Brush.DateTimePicker", "", "DataEntry" ], [ "DatePicker", "DatePickerDemo", "Brush.DateTimePicker", "", "DataEntry" ],
[ "Clock", "ClockDemo", "Brush.Time", "", "DataEntry" ], [ "Clock", "ClockDemo", "Brush.Time", "", "DataEntry" ],
@@ -53,6 +53,7 @@
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
<TextBox Text="This is the content" <TextBox Text="This is the content"
PasswordChar="●"
Theme="{StaticResource TextBox.Small}" /> Theme="{StaticResource TextBox.Small}" />
<TextBox Text="This is the content" <TextBox Text="This is the content"
Margin="0,16,0,0" Margin="0,16,0,0"
@@ -60,14 +60,16 @@
Opacity="1" Opacity="1"
x:Name="indeterminateMark" /> x:Name="indeterminateMark" />
</Panel> </Panel>
<ContentPresenter x:Name="contentPresenter" <ContentPresenter Name="PART_ContentPresenter"
IsVisible="{Binding $self.Content, Converter={x:Static ObjectConverters.IsNotNull}}"
Grid.Column="1" Grid.Column="1"
Focusable="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}" 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" RecognizesAccessKey="True"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> TextElement.Foreground="{TemplateBinding Foreground}" />
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
@@ -28,12 +28,6 @@
Height="16" Height="16"
Margin="4,0,1,0" Margin="4,0,1,0"
Background="Transparent"> Background="Transparent">
<Canvas.Styles>
<Style Selector="ToolTip">
<Setter Property="BorderBrush"
Value="{DynamicResource DangerBrush}" />
</Style>
</Canvas.Styles>
<ToolTip.Tip> <ToolTip.Tip>
<ItemsControl x:DataType="DataValidationErrors" <ItemsControl x:DataType="DataValidationErrors"
ItemsSource="{Binding}" /> 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/Basic/Converters.axaml" />
<MergeResourceInclude Source="/Themes/Styles/DataValidationErrors.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/TextBlock.axaml" />
<MergeResourceInclude Source="/Themes/Styles/ContentControl.axaml" /> <MergeResourceInclude Source="/Themes/Styles/ContentControl.axaml" />
<MergeResourceInclude Source="/Themes/Styles/UserControl.axaml" /> <MergeResourceInclude Source="/Themes/Styles/UserControl.axaml" />
@@ -11458,16 +11458,18 @@
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<Style x:Key="ToolTipBaseStyle" TargetType="ToolTip"> <Style x:Key="ToolTipBaseStyle" TargetType="ToolTip">
<Setter Property="Padding" Value="0,6" /> <Setter Property="Padding" Value="{StaticResource DefaultControlPadding}" />
<Setter Property="Background" Value="White" /> <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="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
<Setter Property="FontSize" Value="12" /> <Setter Property="FontSize" Value="12" />
<Setter Property="hc:BorderElement.CornerRadius" Value="2" /> <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="ToolTip"> <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}"> <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 Margin="10,0" /> <ContentPresenter />
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
@@ -2,17 +2,32 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="clr-namespace:HandyControl.Controls"> xmlns:hc="clr-namespace:HandyControl.Controls">
<Style x:Key="ToolTipBaseStyle" TargetType="ToolTip"> <Style x:Key="ToolTipBaseStyle"
<Setter Property="Padding" Value="0,6"/> TargetType="ToolTip">
<Setter Property="Background" Value="White"/> <Setter Property="Padding"
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/> Value="{StaticResource DefaultControlPadding}" />
<Setter Property="FontSize" Value="12"/> <Setter Property="Background"
<Setter Property="hc:BorderElement.CornerRadius" Value="2"/> 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 Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="ToolTip"> <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}"> <Border Effect="{StaticResource EffectShadow2}"
<ContentPresenter Margin="10,0"/> Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}"
BorderThickness="1"
CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}"
BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter />
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
@@ -11577,16 +11577,18 @@
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<Style x:Key="ToolTipBaseStyle" TargetType="ToolTip"> <Style x:Key="ToolTipBaseStyle" TargetType="ToolTip">
<Setter Property="Padding" Value="0,6" /> <Setter Property="Padding" Value="{StaticResource DefaultControlPadding}" />
<Setter Property="Background" Value="White" /> <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="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
<Setter Property="FontSize" Value="12" /> <Setter Property="FontSize" Value="12" />
<Setter Property="hc:BorderElement.CornerRadius" Value="2" /> <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="ToolTip"> <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}"> <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 Margin="10,0" /> <ContentPresenter />
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>