Results 1 to 5 of 5

Thread: Templates of Visual Studio for Windows Phone 7

  1. #1
    Join Date
    Jul 2010
    Posts
    142

    Templates of Visual Studio for Windows Phone 7

    To start developing a project, as always, choose the template project from Visual Studio: in the final version features several types of projects, broken down into XNA and Silverlight. XNA templates provide the ability to create the main project using the Windows Template Phone Game (4.0) or a class library using the Windows Template Library Phone Game (4.0). Silverlight for Windows in the section we find several templates Phone:
    1. Phone is the Windows Application template for creating an application in more traditional terms: we will have the designers of Visual Studio and XAML code editor to compose the pages and on the code behind.
    2. Phone Windows Class Library, allows the creation of a dll (assembly .NET) to centralize the common classes for reuse in various projects or to create the various layers of the application itself.
    3. Panorama Window Phone Application, is a project derived from Windows Phone Application proposes, on the main page, use this control Panorama: go into the details.
    4. Pivot Window Phone Application is a project which is also derived from Windows Phone Application proposes, on the main page, use this control Pivot, which is the modern substitute in the Tab Control.
    5. Phone Databound Windows Application, you can create applications based on a sailing master / detail following specifications METRO.

  2. #2
    Join Date
    Feb 2010
    Posts
    390

    Re: Templates of Visual Studio for Windows 7 Phone


    ApplicationIcon.png is the file used when installing the device for 'application icon, and SplashScreenImage.jpg the image is used when starting the application itself as a Splash Screen.

    The third image is in png format instead of the image used for the start menu. The user, based on the specific METRO, can choose which applications to "carry" in the start menu of the phone, so it is always at hand. When the user performs this operation ('pin to start "is the correct terminology), the latter image is used to represent the application on the home phone. As you can see the application consists of three files .xaml and two directories. The App.xaml represents the definition of the application, its resources, sharing of styles to all pages, its code-behind contains events that we can intercept application to perform: for example, you can catch the event Application_Launching to catch the start of the application or the event Application_UnhandledException to catch unhandled exceptions in the code of various pages.

  3. #3
    Join Date
    Feb 2010
    Posts
    638

    Re: Templates of Visual Studio for Windows 7 Phone

    Page MainPage presents the following XAML (the cut is not important for reasons of space):
    Code:
    <Phone: PhoneApplicationPage
       x: Class = "ThinkMore.DataBoundTrial.MainPage"
       xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       <! - Omitted the import namespace ->
       <! - And reporting the parameters of the page ->
     >
    
    
     <Grid X:Name="LayoutRoot" Background="Transparent">
       <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="*" />
       </ Grid.RowDefinitions>
      
       <! - TitlePanel contains the name of the application to page title ->
       <StackPanel X:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
         <TextBlock X:Name="ApplicationTitle" Text="DEVELOP GROUP" Style="{StaticResource PhoneTextNormalStyle}" />
    	 <TextBlock X:Name="PageTitle" Text="Company" Style="{StaticResource PhoneTextTitle1Style}" />
       </ StackPanel>
      
       <! - ContentPanel contains ListBox and ListBox ItemTemplate.  Place additional content here ->
       <Grid X:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
         <ListBox X:Name="MainListBox" Margin="0,0,-12,0" ItemSource="{Binding Items}" SelectionChanged="MainListBox_SelectionChanged">
    	   <ListBox.ItemTemplate>
    	     <DataTemplate>
    		   <StackPanel Margin="0,0,0,17" width="432">
    		     <TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLarge}" />
    			 <TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}" />
    		   </ StackPanel>
    		 </ DataTemplate>
    	   </ ListBox.ItemTemplate>
    	 </ ListBox>
       </ Grid>
     </ Grid>
    
     </ Phone: PhoneApplicationPage>
    After the class definition of the main page and its XML namespace, the code offers a grid to separate the application title page and the content of the page. The first row of the Grid in fact contains two TextBlock with the license application and the title page itself, which we have suitably modified to adhere to the example we will do.

  4. #4
    Join Date
    Feb 2010
    Posts
    532

    Re: Templates of Visual Studio for Windows 7 Phone

    The coding given by the "Savannah87" is correct (maybe, but I have not checked that practically yet. Will let you know once I have done with it). The second row of the grid, which in the traditional template would be empty, but contains a ListBox named MainListBox in binding through ItemSource, with the property Items that we will discover shortly. The template for the various items in the listbox has been redefined to accommodate two TextBlock with different style settings. Pressing F5 will start the emulator that has the list, with dummy data for now, with two-line elements, where the first line adheres to the style PhoneTextExtraLargeStyle and the second style PhoneTextSubtleStyle . These two styles have been defined by Microsoft and fit the theme chosen by the user interface for all of the phone. The part of the code-behind code used to open the detail when the user selects (run the tap on the screen) an element of the list box: the classic event SelectionChanged is used to intercept the user's selection and open the form in detail.

  5. #5
    Join Date
    Feb 2010
    Posts
    131

    Re: Coding for Templates of Visual Studio for Windows 7 Phone

    Here is the code of the code-behind without any change from the template of Visual Studio:
    Code:
     using System;
     using System.Collections.Generic;
     using System.Linq;
     using System.Net;
     using System.Windows;
     using System.Windows.Controls;
     using System.Windows.Documents;
     using System.Windows.Input;
     using System.Windows.Media;
     using System.Windows.Media.Animation;
     using System.Windows.Shapes;
     using Microsoft.Phone.Controls;
    
     namespace ThinkAhead.DataBoundSample
     {
       public partial class MainPage: PhoneApplicationPage
       {
         / / Constructor
    	 public MainPage ()
    	 {
    	   InitializeComponent ();
    	  
    	   / / Set the data context of the ListBox control to sample data
    	   DataContent = App.ViewModel;
    	   this.Loaded + = new RoutedEventHandler (MainPage_Loaded);
    	 }
    	
    	 / / Handle selection changed on ListBox
    	 private void MainListBox_SelectionChanged (object sender, SelectionChangedEventArgs s)
    	 {
    	   / / If selected index is -1 (no selection) do nothing
    	   if (MainListBox.SelectedIndex == -1) return;
    	  
    	   / / Navigate to new page
    	   NavigationService.Navigate (new Uri ("/ DetailsPage.xaml? SelectedItem ="
    	       + MainListBox.SelectedIndex, UriKind.Relative));
    		  
           / / Reset selected index to -1 (no selection)
    	   MainListBox.SelectedIndex = -1;
    	 }
    	
    	 / / Load data for the ViewModel Items
    	 private void MainPage_Loaded (object sender, RoutedEventArgs e)
    	 {
    	   if (! App.ViewModel.IsDataLoaded)
    	   {
    	     App.ViewModel.LoadData ();
    	   }
    	 }
       }
     }
    The event SelectionChanged of listbox control that the user has selected an item to navigate to the page DetailsPage.xaml which is passed the index of the listbox itself. As I mentioned at the beginning of the example the goal is to open the form of detail of each item. As you can see from the code, the listbox is populated by direct binding property Items . The Items property is exposed by the class App.ViewModel that is put on the entire binding DataContext of the page.

Similar Threads

  1. Windows phone 7 : Issue on Visual studio 2008
    By Keval-B in forum Windows Software
    Replies: 7
    Last Post: 01-03-2011, 11:51 PM
  2. Replies: 2
    Last Post: 16-02-2011, 02:49 PM
  3. Replies: 6
    Last Post: 11-11-2010, 06:41 PM
  4. Compare Visual Studio 2010 and Visual Web Developer Express
    By Zacharia in forum Software Development
    Replies: 5
    Last Post: 28-01-2010, 04:27 AM
  5. Difference between Visual studio 2005 and Visual studio 2008
    By RohanS in forum Software Development
    Replies: 3
    Last Post: 12-06-2009, 10:48 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,648,287.00476 seconds with 17 queries