Skip to content

Commit 9697e99

Browse files
committed
feat: add avalonia ToolTip style.
1 parent 7047087 commit 9697e99

File tree

10 files changed

+110
-31
lines changed

10 files changed

+110
-31
lines changed

src/Avalonia/HandyControlDemo_Avalonia/Data/DemoInfo.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
[ "TextBlock", "TextBlockDemo", "Brush.TextBlock", "", "" ],
1616
[ "TextBox", "TextBoxDemo", "Brush.TextBox", "", "" ],
1717
[ "ComboBox", "NativeComboBoxDemo", "Brush.ComboBox", "", "" ],
18-
[ "PasswordBox", "NativePasswordBoxDemo", "Brush.PasswordBox", "", "" ],
1918
[ "Expander", "ExpanderDemo", "Brush.Expander", "", "" ],
2019
[ "ProgressBar", "NativeProgressBarDemo", "Brush.ProgressBar", "", "" ],
2120
[ "Calendar", "CalendarDemo", "Brush.Calendar", "", "" ],
@@ -55,7 +54,6 @@
5554
[ "ComboBox", "ComboBoxDemo", "Brush.ComboBox", "", "DataEntry" ],
5655
[ "CheckComboBox", "CheckComboBoxDemo", "Brush.CheckBoxList", "", "DataEntry" ],
5756
[ "AutoCompleteTextBox", "AutoCompleteTextBoxDemo", "Brush.AutoComplete", "1", "DataEntry" ],
58-
[ "PasswordBox", "PasswordBoxDemo", "Brush.PasswordBox", "", "DataEntry" ],
5957
[ "PinBox", "PinBoxDemo", "Brush.Ellipsis", "", "DataEntry" ],
6058
[ "DatePicker", "DatePickerDemo", "Brush.DateTimePicker", "", "DataEntry" ],
6159
[ "Clock", "ClockDemo", "Brush.Time", "", "DataEntry" ],

src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/TextBoxDemo.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
</StackPanel>
5454
<StackPanel>
5555
<TextBox Text="This is the content"
56+
PasswordChar=""
5657
Theme="{StaticResource TextBox.Small}" />
5758
<TextBox Text="This is the content"
5859
Margin="0,16,0,0"

src/Avalonia/HandyControl_Avalonia/Themes/Styles/CheckBox.axaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@
6060
Opacity="1"
6161
x:Name="indeterminateMark" />
6262
</Panel>
63-
<ContentPresenter x:Name="contentPresenter"
64-
IsVisible="{Binding $self.Content, Converter={x:Static ObjectConverters.IsNotNull}}"
63+
<ContentPresenter Name="PART_ContentPresenter"
6564
Grid.Column="1"
66-
Focusable="False"
67-
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
6865
Margin="{TemplateBinding Padding}"
66+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
67+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
68+
Content="{TemplateBinding Content}"
69+
ContentTemplate="{TemplateBinding ContentTemplate}"
70+
IsVisible="{TemplateBinding Content, Converter={x:Static ObjectConverters.IsNotNull}}"
6971
RecognizesAccessKey="True"
70-
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
72+
TextElement.Foreground="{TemplateBinding Foreground}" />
7173
</Grid>
7274
</ControlTemplate>
7375
</Setter>

src/Avalonia/HandyControl_Avalonia/Themes/Styles/DataValidationErrors.axaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828
Height="16"
2929
Margin="4,0,1,0"
3030
Background="Transparent">
31-
<Canvas.Styles>
32-
<Style Selector="ToolTip">
33-
<Setter Property="BorderBrush"
34-
Value="{DynamicResource DangerBrush}" />
35-
</Style>
36-
</Canvas.Styles>
3731
<ToolTip.Tip>
3832
<ItemsControl x:DataType="DataValidationErrors"
3933
ItemsSource="{Binding}" />
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<ResourceDictionary xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
<ControlTheme x:Key="{x:Type PopupRoot}"
4+
TargetType="PopupRoot">
5+
<Setter Property="Background"
6+
Value="{x:Null}" />
7+
<Setter Property="TransparencyLevelHint"
8+
Value="Transparent" />
9+
<Setter Property="Foreground"
10+
Value="{DynamicResource PrimaryTextBrush}" />
11+
<Setter Property="Template">
12+
<ControlTemplate>
13+
<LayoutTransformControl LayoutTransform="{TemplateBinding Transform}">
14+
<Panel>
15+
<Border Name="PART_TransparencyFallback"
16+
IsHitTestVisible="False" />
17+
<VisualLayerManager IsPopup="True">
18+
<ContentPresenter Name="PART_ContentPresenter"
19+
Background="{TemplateBinding Background}"
20+
ContentTemplate="{TemplateBinding ContentTemplate}"
21+
Content="{TemplateBinding Content}"
22+
Padding="{TemplateBinding Padding}" />
23+
</VisualLayerManager>
24+
</Panel>
25+
</LayoutTransformControl>
26+
</ControlTemplate>
27+
</Setter>
28+
</ControlTheme>
29+
</ResourceDictionary>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<ResourceDictionary xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:hc="https://handyorg.github.io/handycontrol">
4+
<ControlTheme x:Key="{x:Type ToolTip}"
5+
TargetType="ToolTip">
6+
<Setter Property="Padding"
7+
Value="{StaticResource DefaultControlPadding}" />
8+
<Setter Property="Background"
9+
Value="{DynamicResource RegionBrush}" />
10+
<Setter Property="BorderBrush"
11+
Value="{DynamicResource BorderBrush}" />
12+
<Setter Property="BorderThickness"
13+
Value="1" />
14+
<Setter Property="Foreground"
15+
Value="{DynamicResource PrimaryTextBrush}" />
16+
<Setter Property="FontSize"
17+
Value="12" />
18+
<Setter Property="hc:BorderElement.CornerRadius"
19+
Value="{StaticResource DefaultCornerRadius}" />
20+
<Setter Property="Template">
21+
<ControlTemplate>
22+
<ContentPresenter Name="PART_ContentPresenter"
23+
Effect="{StaticResource EffectShadow2}"
24+
Background="{TemplateBinding Background}"
25+
Padding="{TemplateBinding Padding}"
26+
BorderThickness="{TemplateBinding BorderThickness}"
27+
CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
28+
BorderBrush="{TemplateBinding BorderBrush}"
29+
Content="{TemplateBinding Content}"
30+
ContentTemplate="{TemplateBinding ContentTemplate}" />
31+
</ControlTemplate>
32+
</Setter>
33+
</ControlTheme>
34+
</ResourceDictionary>

src/Avalonia/HandyControl_Avalonia/Themes/Theme.axaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<MergeResourceInclude Source="/Themes/Basic/Converters.axaml" />
1717

1818
<MergeResourceInclude Source="/Themes/Styles/DataValidationErrors.axaml" />
19+
<MergeResourceInclude Source="/Themes/Styles/PopupRoot.axaml" />
20+
<MergeResourceInclude Source="/Themes/Styles/ToolTip.axaml" />
1921
<MergeResourceInclude Source="/Themes/Styles/TextBlock.axaml" />
2022
<MergeResourceInclude Source="/Themes/Styles/ContentControl.axaml" />
2123
<MergeResourceInclude Source="/Themes/Styles/UserControl.axaml" />

src/Net_40/HandyControl_Net_40/Themes/Theme.xaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11458,16 +11458,18 @@
1145811458
</Style.Triggers>
1145911459
</Style>
1146011460
<Style x:Key="ToolTipBaseStyle" TargetType="ToolTip">
11461-
<Setter Property="Padding" Value="0,6" />
11462-
<Setter Property="Background" Value="White" />
11461+
<Setter Property="Padding" Value="{StaticResource DefaultControlPadding}" />
11462+
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
11463+
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
11464+
<Setter Property="BorderThickness" Value="1" />
1146311465
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
1146411466
<Setter Property="FontSize" Value="12" />
11465-
<Setter Property="hc:BorderElement.CornerRadius" Value="2" />
11467+
<Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}" />
1146611468
<Setter Property="Template">
1146711469
<Setter.Value>
1146811470
<ControlTemplate TargetType="ToolTip">
11469-
<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}">
11470-
<ContentPresenter Margin="10,0" />
11471+
<Border Effect="{StaticResource EffectShadow2}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" BorderThickness="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}">
11472+
<ContentPresenter />
1147111473
</Border>
1147211474
</ControlTemplate>
1147311475
</Setter.Value>

src/Shared/HandyControl_Shared/Themes/Styles/Base/ToolTipBaseStyle.xaml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,32 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:hc="clr-namespace:HandyControl.Controls">
44

5-
<Style x:Key="ToolTipBaseStyle" TargetType="ToolTip">
6-
<Setter Property="Padding" Value="0,6"/>
7-
<Setter Property="Background" Value="White"/>
8-
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
9-
<Setter Property="FontSize" Value="12"/>
10-
<Setter Property="hc:BorderElement.CornerRadius" Value="2"/>
5+
<Style x:Key="ToolTipBaseStyle"
6+
TargetType="ToolTip">
7+
<Setter Property="Padding"
8+
Value="{StaticResource DefaultControlPadding}" />
9+
<Setter Property="Background"
10+
Value="{DynamicResource RegionBrush}" />
11+
<Setter Property="BorderBrush"
12+
Value="{DynamicResource BorderBrush}" />
13+
<Setter Property="BorderThickness"
14+
Value="1" />
15+
<Setter Property="Foreground"
16+
Value="{DynamicResource PrimaryTextBrush}" />
17+
<Setter Property="FontSize"
18+
Value="12" />
19+
<Setter Property="hc:BorderElement.CornerRadius"
20+
Value="{StaticResource DefaultCornerRadius}" />
1121
<Setter Property="Template">
1222
<Setter.Value>
1323
<ControlTemplate TargetType="ToolTip">
14-
<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}">
15-
<ContentPresenter Margin="10,0"/>
24+
<Border Effect="{StaticResource EffectShadow2}"
25+
Background="{TemplateBinding Background}"
26+
Padding="{TemplateBinding Padding}"
27+
BorderThickness="1"
28+
CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}"
29+
BorderBrush="{TemplateBinding BorderBrush}">
30+
<ContentPresenter />
1631
</Border>
1732
</ControlTemplate>
1833
</Setter.Value>

src/Shared/HandyControl_Shared/Themes/Theme.xaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11577,16 +11577,18 @@
1157711577
</Style.Triggers>
1157811578
</Style>
1157911579
<Style x:Key="ToolTipBaseStyle" TargetType="ToolTip">
11580-
<Setter Property="Padding" Value="0,6" />
11581-
<Setter Property="Background" Value="White" />
11580+
<Setter Property="Padding" Value="{StaticResource DefaultControlPadding}" />
11581+
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
11582+
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
11583+
<Setter Property="BorderThickness" Value="1" />
1158211584
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
1158311585
<Setter Property="FontSize" Value="12" />
11584-
<Setter Property="hc:BorderElement.CornerRadius" Value="2" />
11586+
<Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}" />
1158511587
<Setter Property="Template">
1158611588
<Setter.Value>
1158711589
<ControlTemplate TargetType="ToolTip">
11588-
<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}">
11589-
<ContentPresenter Margin="10,0" />
11590+
<Border Effect="{StaticResource EffectShadow2}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" BorderThickness="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}">
11591+
<ContentPresenter />
1159011592
</Border>
1159111593
</ControlTemplate>
1159211594
</Setter.Value>

0 commit comments

Comments
 (0)