Tuesday, June 7, 2016

Lesson 6: Windows Mobile Application: A Simple example of Page Navigations


Here is an Application to display Health tips based on the Season.I have used four pages in this app.Follow the instructions given below.
1.   On the menu bar, choose File, New, and Project.
2.   Choose Programming language as  Visual C# . In the templates list,       choose the Windows Phone  and then choose Windows Phone App.
3.   Name the project as HealthTips and specify the address of your folder.

4.   In the design window of the home page design as shown below.

Page 1

Following controls and their corresponding properties are given below.(For page 1)
            1. Content Panel Grid->Brush -> BackGround  
Stretch=Fill
ImageSource="/Assets/mY IMAGE.jpg"
        2. TextBlock Name=StackPanelTextBlock1
Text=Health Application
        3. TextBlock Name=StackPanelTextBlock2
Text=Home Page
        4. Button Name=btnSummer 
Content=Summer
Brush -> BackGround -> Gradient Brush -> Blue, Pink 
        5. Button Name=btnWinter 
Content=Winter
Brush ->;BackGround -> Gradient Brush -> Blue, Pink 
        6. Button Name=btnWinter 
Content=Mansoon
Brush -> BackGround ->Gradient Brush->Blue, Pink

   Go to the Solution Explorer. Right Click on the name of the project. Press        Add in the menu Ad then press Add item and then add a new Windows        
   Phone  Portrait Page In the design window of the Summer page design as        shown below.
   

Summer.xaml Page
Following controls and their corresponding properties are given below.(For page 2)
     1. Content Panel Grid Brush  BackGround  
Stretch=Fill
ImageSource=/Assets/images.jpg
     2. TextBlock Name=StackPanelTextBlock1
Text=Health Application
     3. TextBlock Name=StackPanelTextBlock2
Text=Summer Page
     4.   Button Name=btnGoBackSummer 
Content=Go Back
Brush -> BackGround ->Gradient Brush -> Red, Blue 
     5.  TextBlocks Add Different Text Block According to the matter to be    
          displayed

Go to the Solution Explorer. Right Click on the name of the project. Press Add in the menu Ad then press Add item and then add a new Windows Phone Portrait Page
In the design window of the Winter page design as shown below.

Winter.xaml Page
Following controls and their corresponding properties are given below.(For page 3)


     1. Content Panel Grid Brush -> BackGround  
Stretch=Fill
ImageSource=/Assets/images (10).jpg
     2. TextBlock Name=StackPanelTextBlock1
Text=Health Application
     3. TextBlock Name=StackPanelTextBlock2
Text=Summer Page
     4.  Button Name=btnGoBackSummer 
Content=Go Back
Brush -> BackGround -> Gradient Brush -> Red, Blue 
     5. Text Blocks Add Different Text Block as per your requirement to display           text on your page.

Go to the Solution Explorer. Right Click on the name of the project. Press Add in the menu Ad then press Add item and then add a new Windows Phone Portrait Page. In the design window of the Mansoon page design as shown below.

Mansoon.xaml Page
Following controls and their corresponding properties are given below.(For page 4)


     1. Content Panel Grid: Brush ->; BackGround  
Stretch=Fill
ImageSource=/Assets/images (9).jpg
     2. TextBlock Name=StackPanelTextBlock1
Text=Health Application
     3. TextBlock Name=StackPanelTextBlock2
Text=Mansoon Page
     4.  Button Name=btnGoBackMansoon
Content=Go Back
Brush -> BackGround ->Gradient Brush -> Red, Blue 
     5 TextBlocks: Add Different Text Block According to the matter to be    
        displayed

     Now, Double click the buttons , corresponding xaml.cs window will be          opened . Type the following code.  

    private void btnSummer_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Summer.xaml",            
            UriKind.Relative));
        }

       
     private void btnWinter_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Winter.xaml",           
            UriKind.Relative));
        }

       
     private void btnMansoon_Click(object sender, RoutedEventArgs e)
        {
           NavigationService.Navigate(new Uri("/Mansoon.xaml",          
          UriKind.Relative));
        }
         

     private void btnGoBackSummer_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.GoBack();
        }


      private void btnGoBackWinter_Click(object sender, RoutedEventArgs e)
         {
            this.NavigationService.GoBack();
         }


      private void btnGoBackMansoon_Click(object sender, RoutedEventArgs e)
         {
            this.NavigationService.GoBack();
         }

Run the project and see the result. 

    Fun Programming!!




No comments:

Post a Comment