Skip to content

Commit fb2784f

Browse files
committed
enhance: avalonia HyperlinkButton style.
1 parent 64da563 commit fb2784f

File tree

2 files changed

+152
-8
lines changed

2 files changed

+152
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,27 @@
1717
IsEnabled="False" />
1818

1919
<HyperlinkButton Content="HandyControl"
20-
Classes="ghost"
20+
Theme="{StaticResource HyperlinkButtonGhost}"
2121
NavigateUri="https://github.com/HandyOrg/HandyControl" />
2222
<HyperlinkButton Content="HandyControl"
23-
Classes="ghost primary"
23+
Theme="{StaticResource HyperlinkButtonGhostPrimary}"
2424
NavigateUri="https://github.com/HandyOrg/HandyControl" />
2525
<HyperlinkButton Content="HandyControl"
26-
Classes="ghost success"
26+
Theme="{StaticResource HyperlinkButtonGhostSuccess}"
2727
NavigateUri="https://github.com/HandyOrg/HandyControl" />
2828
<HyperlinkButton Content="HandyControl"
29-
Classes="ghost info"
29+
Theme="{StaticResource HyperlinkButtonGhostInfo}"
3030
NavigateUri="https://github.com/HandyOrg/HandyControl" />
3131
<HyperlinkButton Content="HandyControl"
32-
Classes="ghost warning"
32+
Theme="{StaticResource HyperlinkButtonGhostWarning}"
3333
NavigateUri="https://github.com/HandyOrg/HandyControl" />
3434
<HyperlinkButton Content="HandyControl"
35-
Classes="ghost danger"
35+
Theme="{StaticResource HyperlinkButtonGhostDanger}"
3636
NavigateUri="https://github.com/HandyOrg/HandyControl" />
3737
</hc:UniformSpacingPanel>
3838
</Border>
3939
<Border Theme="{StaticResource BorderRegion}">
40-
<hc:UniformSpacingPanel Spacing="16"+
41-
40+
<hc:UniformSpacingPanel Spacing="16"
4241
Orientation="Vertical">
4342
<HyperlinkButton Content="HandyControl"
4443
Classes="small"
@@ -48,6 +47,9 @@
4847
NavigateUri="https://github.com/HandyOrg/HandyControl"
4948
IsEnabled="False" />
5049

50+
<HyperlinkButton Content="HandyControl"
51+
Classes="ghost small"
52+
NavigateUri="https://github.com/HandyOrg/HandyControl" />
5153
<HyperlinkButton Content="HandyControl"
5254
Classes="ghost primary small"
5355
NavigateUri="https://github.com/HandyOrg/HandyControl" />

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

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,150 @@
6666
</Style>
6767
</ControlTheme>
6868

69+
<ControlTheme x:Key="HyperlinkButtonDefault"
70+
BasedOn="{StaticResource HyperlinkButtonBaseStyle}"
71+
TargetType="HyperlinkButton" />
72+
73+
<ControlTheme x:Key="HyperlinkButtonDefault.Small"
74+
BasedOn="{StaticResource HyperlinkButtonBaseStyle}"
75+
TargetType="HyperlinkButton">
76+
<Setter Property="Height"
77+
Value="20" />
78+
<Setter Property="Padding"
79+
Value="6,1" />
80+
<Setter Property="hc:IconElement.Height"
81+
Value="12" />
82+
</ControlTheme>
83+
6984
<ControlTheme x:Key="{x:Type HyperlinkButton}"
7085
BasedOn="{StaticResource HyperlinkButtonBaseStyle}"
7186
TargetType="HyperlinkButton" />
7287

88+
<ControlTheme x:Key="HyperlinkButtonGhost"
89+
BasedOn="{StaticResource HyperlinkButtonBaseStyle}"
90+
TargetType="HyperlinkButton">
91+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverBackground"
92+
Value="{DynamicResource SecondaryRegionBrush}" />
93+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverForeground"
94+
Value="{DynamicResource PrimaryTextBrush}" />
95+
96+
<Style Selector="^:pointerover">
97+
<Setter Property="Background"
98+
Value="{Binding $self.(hc:BackgroundSwitchElement.MouseHoverBackground)}" />
99+
<Setter Property="Foreground"
100+
Value="{Binding $self.(hc:BackgroundSwitchElement.MouseHoverForeground)}" />
101+
</Style>
102+
</ControlTheme>
103+
104+
<ControlTheme x:Key="HyperlinkButtonGhost.Small"
105+
BasedOn="{StaticResource HyperlinkButtonGhost}"
106+
TargetType="HyperlinkButton">
107+
<Setter Property="Height"
108+
Value="20" />
109+
<Setter Property="Padding"
110+
Value="6,1" />
111+
<Setter Property="hc:IconElement.Height"
112+
Value="12" />
113+
</ControlTheme>
114+
115+
<ControlTheme x:Key="HyperlinkButtonGhostPrimary"
116+
BasedOn="{StaticResource HyperlinkButtonGhost}"
117+
TargetType="HyperlinkButton">
118+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverBackground"
119+
Value="{DynamicResource PrimaryBrush}" />
120+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverForeground"
121+
Value="{DynamicResource TextIconBrush}" />
122+
</ControlTheme>
123+
124+
<ControlTheme x:Key="HyperlinkButtonGhostPrimary.Small"
125+
BasedOn="{StaticResource HyperlinkButtonGhostPrimary}"
126+
TargetType="HyperlinkButton">
127+
<Setter Property="Height"
128+
Value="20" />
129+
<Setter Property="Padding"
130+
Value="6,1" />
131+
<Setter Property="hc:IconElement.Height"
132+
Value="12" />
133+
</ControlTheme>
134+
135+
<ControlTheme x:Key="HyperlinkButtonGhostSuccess"
136+
BasedOn="{StaticResource HyperlinkButtonGhost}"
137+
TargetType="HyperlinkButton">
138+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverBackground"
139+
Value="{DynamicResource SuccessBrush}" />
140+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverForeground"
141+
Value="{DynamicResource TextIconBrush}" />
142+
</ControlTheme>
143+
144+
<ControlTheme x:Key="HyperlinkButtonGhostSuccess.Small"
145+
BasedOn="{StaticResource HyperlinkButtonGhostSuccess}"
146+
TargetType="HyperlinkButton">
147+
<Setter Property="Height"
148+
Value="20" />
149+
<Setter Property="Padding"
150+
Value="6,1" />
151+
<Setter Property="hc:IconElement.Height"
152+
Value="12" />
153+
</ControlTheme>
154+
155+
<ControlTheme x:Key="HyperlinkButtonGhostInfo"
156+
BasedOn="{StaticResource HyperlinkButtonGhost}"
157+
TargetType="HyperlinkButton">
158+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverBackground"
159+
Value="{DynamicResource InfoBrush}" />
160+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverForeground"
161+
Value="{DynamicResource TextIconBrush}" />
162+
</ControlTheme>
163+
164+
<ControlTheme x:Key="HyperlinkButtonGhostInfo.Small"
165+
BasedOn="{StaticResource HyperlinkButtonGhostInfo}"
166+
TargetType="HyperlinkButton">
167+
<Setter Property="Height"
168+
Value="20" />
169+
<Setter Property="Padding"
170+
Value="6,1" />
171+
<Setter Property="hc:IconElement.Height"
172+
Value="12" />
173+
</ControlTheme>
174+
175+
<ControlTheme x:Key="HyperlinkButtonGhostWarning"
176+
BasedOn="{StaticResource HyperlinkButtonGhost}"
177+
TargetType="HyperlinkButton">
178+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverBackground"
179+
Value="{DynamicResource WarningBrush}" />
180+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverForeground"
181+
Value="{DynamicResource TextIconBrush}" />
182+
</ControlTheme>
183+
184+
<ControlTheme x:Key="HyperlinkButtonGhostWarning.Small"
185+
BasedOn="{StaticResource HyperlinkButtonGhostWarning}"
186+
TargetType="HyperlinkButton">
187+
<Setter Property="Height"
188+
Value="20" />
189+
<Setter Property="Padding"
190+
Value="6,1" />
191+
<Setter Property="hc:IconElement.Height"
192+
Value="12" />
193+
</ControlTheme>
194+
195+
<ControlTheme x:Key="HyperlinkButtonGhostDanger"
196+
BasedOn="{StaticResource HyperlinkButtonGhost}"
197+
TargetType="HyperlinkButton">
198+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverBackground"
199+
Value="{DynamicResource DangerBrush}" />
200+
<Setter Property="hc:BackgroundSwitchElement.MouseHoverForeground"
201+
Value="{DynamicResource TextIconBrush}" />
202+
</ControlTheme>
203+
204+
<ControlTheme x:Key="HyperlinkButtonGhostDanger.Small"
205+
BasedOn="{StaticResource HyperlinkButtonGhostDanger}"
206+
TargetType="HyperlinkButton">
207+
<Setter Property="Height"
208+
Value="20" />
209+
<Setter Property="Padding"
210+
Value="6,1" />
211+
<Setter Property="hc:IconElement.Height"
212+
Value="12" />
213+
</ControlTheme>
214+
73215
</ResourceDictionary>

0 commit comments

Comments
 (0)