wpf link button

Link button in wpf

you want to make a button to look like hyper link.

<Button Margin="3,0,0,0" Content="Visit Website" Cursor="Hand" x:Name="VisitWebsite" Click="VisitWebsite_Click">
                    <Button.Template>
                        <ControlTemplate TargetType="Button">
                            <TextBlock TextDecorations="Underline"> 
                <ContentPresenter />
                            </TextBlock>
                        </ControlTemplate>
                    </Button.Template>
                    <Button.Style>
                        <Style TargetType="Button">
                            <Setter Property="Foreground" Value="Blue" />
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter Property="Foreground" Value="Red" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                </Button>

In style :

<Style 
    x:Key="LinkButon" 
    TargetType="Button"> 
    <Setter 
        Property="Template"> 
        <Setter.Value> 
            <ControlTemplate 
                TargetType="Button"> 
                <TextBlock 
                    TextDecorations="Underline"> 
                <ContentPresenter /></TextBlock> 
            </ControlTemplate> 
        </Setter.Value> 
    </Setter> 
    <Setter 
        Property="Foreground" 
        Value="Blue" /> 
    <Style.Triggers> 
        <Trigger 
            Property="IsMouseOver" 
            Value="true"> 
            <Setter 
                Property="Foreground" 
                Value="Red" /> 
        </Trigger> 
    </Style.Triggers> 
</Style>
wpf link button wpf link button Reviewed by Bhaumik Patel on 5:38 AM Rating: 5