Thursday, 12 December 2013


HOW TO PASS MORE PARAMETERS IN PAGE NAVIGATION OF WINDOWS 8 PHONE


Parameters are most easily passed from one page to another by encoding them into the query string used to navigate to the target page. Below is code from an event handler that will navigate to the target with two parameter values :

private void passParameters_Click(object sender, RoutedEventArgs e)
{
    NavigationService.Navigate(new Uri("/Page2.xaml?msg1=" + textBox1.Text +
                                       "&msg2=" + textBox2.Text,
                                       UriKind.Relative));
}

The example happens to be a Click handler for a Button control, however, any similar code will do. The values in the example are provided by the contents of TextBox controls on the source page, but can come from any source of text.

The point is to format the URI to contain the parameter names and values that the target page is expecting. Parameters and values are encoded as name/value pairs in the form, “name=value” where each name/value pair is separated from its predecessor with an “&” character.

The target page extracts the parameter values in the OnNavigatedTo event handler of the derived target PhoneApplicationPage. If the parameter value is optional, then it is the responsibility of the code in this function to handle the case where the parameter value may be either present or absent. Here is an example that matches the sample above:

protected override voidOnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    base.OnNavigatedTo(e);

    string msg = string.Empty;  // Assume no value provided

    if (NavigationContext.QueryString.TryGetValue("msg1"out msg))
    {
        textBlock1.Text = msg;  // Stores the value in a TextBlock
    }

    msg = string.Empty;         // Assume no value provided
           
    if (NavigationContext.QueryString.TryGetValue("msg2"out msg))
    {
        textBlock2.Text = msg;  // Stores the value in a another TextBlock
    }
}

The example above simply displays each parameter value in the target page; how you actually decide to process such values is application dependent.

How to perform page navigation on Windows Phone


  • It is similar to activity in android programming
  • There are following steps for page navigation in windows phone


In this section, you will create an additional page of content that you can navigate to from your app main page.

To create an additional page

  1. Create a new project by selecting the File | New Project menu command.
  2. The New Project window will be displayed. Expand the Visual C# templates, and then select the Windows Phone templates.
  3. Select the Windows Phone App  template. Fill in the project name as desired.
  4. From the designer view on MainPage.xaml, select page title and change this title text tomain page in the Text properties or in the XAML directly.
    AP_Con_mainpage
  5. Right-click your project name in the Solution Explorer, select Add from the menu, and thenNew Item.
  6. Choose Windows Phone Portrait Page, change the name to SecondPage, and select Add at the bottom of the page.
  7. From the designer view on SecondPage.xaml, select page title and change this title text tosecond page in the Text properties or in the XAML directly.
This section will show you how to navigate back and forth between your MainPage.xaml andSecondPage.xaml.

To navigate between pages

  1. On MainPage.xaml, drag a HyperlinkButton control from the Toolbox onto the designer surface. Select the control and change the Content property to Navigate to Second Page or do this directly in the XAML. You may need to expand the control width to see all of the text.
  2. Double-click the hyperlink button to add an event handler for the hyperlink click event. TheMainPage.xaml.cs file will open.
  3. For the hyperlinkButton1_Click event handler, add the following code:
    private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)
            {
                NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative));
            }
    
    NoteNote:
    You can also accomplish the above in the MainPage.xaml by setting theNavigateUri property for the hyperlink control to the second page. For example:NavigateUri = “/SecondPage.xaml”
  4. On SecondPage.xaml, drag a Button control onto the designer surface. Select the control and change the Content property to Navigate Back to Main Page or do this directly in the XAML. You may need to expand the control width to see all of the text.
  5. Double-click the button to add an event handler for the button click event. TheSecondPage.xaml.cs file will open.
  6. For the button1_Click event handler, add the following code:
      private void button1_Click(object sender, RoutedEventArgs e)
            {
                NavigationService.GoBack();
            }
    
  7. Run the app by selecting the Debug | Start Debugging menu command. This will open the emulator window and launch the app.
When you run the app, you will see that it consists of two pages: the main page and a second page. You can navigate from the main page to the second page using a hyperlink with the destination URI configured in its event handler. You can return from the second page to the main page by using theGoBack() method of the navigation service.
NoteNote:
Although the GoBack() method was used in this example, the hardware Back button would also have the effect of returning to the previous page.
AP_Con_mainnavAP_Con_secnav

Sunday, 1 December 2013

HOW TO CREATE LINK TILE USING CSS AND HTML


  1. It is simply a block of link 
  2. It has hover effect
  3. Hover effect changes the decoration(such as text,background,text size,etc) when mouse comes over text or link


  • HTML code is given by 


<html>
<head>
<style>
#tile
{
background-color:red;
padding:20px 90px;
text-decoration:none;

}
#tile:hover{

background-color:yellow;

}
</style>
</head>
<body>


<a href="http://engineeringtub.blogspot.in/" id="tile">Engineers</a>

</body>
</html>


Output :