Search

Monday, July 28, 2014
0 comments

How to add Hyperlink button control by using code in windows phone

3:07 AMMonday, July 28, 2014
In previous article we have already learned about  Hyperlink Button control.  Using the HyperlinkButton control you can navigate one page to another in windows phone. The following example creates a HyperlinkButton control named hyper and then adds it to ContentPanel grid.

To add the Hyperlink Button control by using code

Open MainPage.xaml.cs.

Add the following code in the constructor.
C#

public MainPage()
        {
            InitializeComponent();
            HyperlinkButton h1 = new HyperlinkButton();
            h1.Content = "My Button";
            ContentPanel.Children.Add(h1);
            h1.Click += new RoutedEventHandler(HyperlinkButton_Click);


            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();

        }

 private void HyperlinkButton_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/secondpage.xaml", UriKind.Relative));
        }

Create Hyperlink Button control instance , assign string to the content property of Hyperlink Button. Now add this control into Content Panel. When we click on it then page navigate to other page. The name of other page is "secondpage.xaml". So raise click event for that, using NavigationService.Navigate ( ) method you can move one page to another.

Code generate the following code

How to add Hyperlink button control by using code in windows phoneHow to add Hyperlink button control by using code in windows phone


Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top