Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

Linkbutton in WPF

Posted by Viral Sarvaiya on May 13, 2011

hello,

Today i learn new thing from my current project,

i have to use the linkbutton in wpf, there are no control like linkbutton as like asp.net control in wpf

we can use the button and set style as like link button…

here is the xaml code for set button as a linkbutton.

<Button Margin="5" Content="Test" Cursor="Hand" Name="BtnTest" Click="BtnTest_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>

now u can see the button is look like a link button

Enjoy coding…

Advertisements

2 Responses to “Linkbutton in WPF”

  1. tejas Bhalani said

    Hi Viral

    I want to use timer in Wpf Browser Application

    I have one page that automatically refersh every 10 sec
    it done in asp.net but how to do that in wpf applicatin
    can you help me?

    • viralsarvaiya said

      Hi Tejas,

      Using System.Windows.Threading;

      Use DispatcherTimer for that.

      private DispatcherTimer timer1;

      and in your page load event,

      timer1 = new DispatcherTimer();
      timer1.Interval = TimeSpan.FromSeconds(1);
      timer1.Tick += timer1_Tick;

      timer1.Start();

      and in your timer_Tick event you can write your logic that you want to check.

      private void timer1_Tick(object sender, EventArgs e)
      {
      //Your Logic
      }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: