<Style x:Key="{x:Type Hyperlink}" TargetType="{x:Type Hyperlink}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Setter Property="Foreground" Value="Red" /> </Trigger> <Trigger Property="IsEnabled" Value="false"> <Setter Property="Foreground" Value="{DynamicResource {x:Static GrayTextBrush}}" /> </Trigger> <Trigger Property="IsEnabled" Value="true"> <Setter Property="Cursor" Value="Hand" /> </Trigger> </Style.Triggers> <Setter Property="Foreground" Value="Blue" /> <Setter Property="TextDecorations" Value="Underline" /> </Style>Oh, a slight surprise for me was that the hyperlink colors are not bound to any SystemColor members. No, they are just Red and Blue nailed in the style. Why?....
Wednesday, December 1, 2010
WPF Hyperlink default style
Tried to find the default style of a Hyperlink and discovered that neither Google, nor Expression Blend or ShowMeTheTemplate have it. So I had to disassemble WPF assembly with .NET Reflector+BAML viewer. Here is the style for Aero NormalColor theme, just for reference purposes:
Labels:
default style,
Hyperlink,
WPF
Subscribe to:
Post Comments (Atom)
Great job man! +1
ReplyDeleteI was looking for the system color for a hyperlink, so this post is very interesting! Thanks for the info.
ReplyDeleteWhy? must be the most common thing that enters my head while doing WPF/XAML.
ReplyDeleteThis is a very helpful find.
Thanks a lot.
This was really helpful in making a LinkLabel for WPF - instead of embedding a Run of text in a Hyperlink inside a TextBox (to get the Hyperlink behavior), I could just set this style (named LinkLabel) and apply it to a TextBox and it looks the same. This helped me avoid the visited behavior (I wanted the link to always look active, not visited), and simplified the XAML. Thanks!
ReplyDeleteThank you very much. It is very useful for me.
ReplyDeleteDo you live in a high value house, perhaps have a holiday home too or maybe you have high value contents, such as some fine art or expensive jewellery? Perhaps your house or The Celeb Net Worth are simply not 'standard'. If so, you'll need to know how to buy high net worth home insurance.
ReplyDeleteGreat and I have a tremendous present: How Much Remodel House house renovation advice
ReplyDelete