WPF - Link Button Style

29. September 2010

    In Some cases, you might want to make a button to look like hyper link. (There is a Hyperlink control, which we can use to open some URL). Here is the simple re-usable style for button to make it look like a Hyper link button (LinkButton).

 

<Style x:Key="LinkButtonStyle" TargetType="{x:Type Button}">        
       
<Setter Property="Template">
           
<Setter.Value>
               
<ControlTemplate TargetType="{x:Type Button}">
                   
<TextBlock TextDecorations="Underline">
                       
<ContentPresenter />
                   
</TextBlock>
               
</ControlTemplate>
           
</Setter.Value>
       
</Setter>
       
<Setter Property="HorizontalContentAlignment" Value="Center"/>
       
<Setter Property="VerticalContentAlignment" Value="Center"/>
       
<Setter Property="Foreground" Value="Blue" />
       
<Setter Property="Cursor" Value="Hand" />
       
<Style.Triggers>
           
<Trigger Property="IsMouseOver" Value="true">
               
<Setter Property="Foreground" Value="Red" />
           
</Trigger>
       
</Style.Triggers>
</Style>

 

 

 

Technical , ,

blog comments powered by Disqus