Window Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Saturday, 24 July 2010

Silverlight on Mobile : Write your first Windows Phone 7 Application with Silverlight

Posted on 10:28 by Unknown

Hi, I am back after a small break in between, well the gap I took just because the moment I started this series, There was a launch by Microsoft for Windows Phone 7 Tools, Yes ! I am talking about Windows Phone 7 Beta Tools which you can download right away. However while moving from CTP to Beta, your journey might not be safe and might go with lots of twist and turns,My fellow Community friend Mayur Tendulkar posted a nice solution here, do check that out so as to ease installation process.

Till the final bits comes to us or device or both, I will be using Beta version of tools henceforth,Whatever is new in Beta I will explore and explain here as we progress with applications.Beta tools will take pain to have Project Templates and Blend 4 for Windows Phone 7 on your machine.Today we are just greeting ourselves by saying “Hello World” and in coming posts we will go much more in depth.

Your first Windows Phone 7 Application :

I have already talked a lot about Emulator,Settings and Configurations etc. So today we will start application building via Visual Studio 2010. So Open your Visual Studio 2010 Instance. File->New Project, You will be able to see new template like this :

Prjtemp

There are by default 3 types of Projects under Silverlight for Windows Phone as :

  • Windows Phone Application – For Normal applications
  • Windows Phone List Application – Provides Navigation Support
  • Windows Phone Class Library – Typical Class Library for WP7

Once you choose “Windows Phone Application” you will get following instance where on left you will be able to design with controls on your Phone like page and on right hand side you can put your XAML,Something like this :

IDE

Typical Project Structure will be like this :

slnexplore

In my coming posts, I will be talking on each mini things in WMAppManifest.xml, Other png files and SplashScreenImage.jpg. At this moment, just understand that while loading your application on emulator, SplashScreenImage will be shown on device. We will soon discuss how you can more customize that experience for your application. To have a flavor of Expression Blend 4 for Windows Phone 7, Let’s put some Button and Textbox via Blend, So just Right Click on MainPage.xaml and choose “Open in Expression Blend” option.You will see following screen in Blend

Blend4WP7 

Do I need to tell more about capabilities of Blend? I think we already done with it in past posts. So lets write C# code and execute our First Application, It will now look like this :

 

DashboardApplicationmsgbox

In the leftmost screen you can see your application listed (See the Highlighted text as “Demo_Hello_World”), Second screen shows the initial screen of application with button and the third screen shows final output. So, your first ever Windows Phone 7 application is Ready !

XAML Code :

<!--TitlePanel contains the name of the application and page title-->
       <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,24,0,12">
           <TextBlock x:Name="ApplicationTitle" Text="Explore .NET with Vikram Pendse" Style="{StaticResource PhoneTextNormalStyle}"/>
           <TextBlock x:Name="PageTitle" Text="Hello World !" Margin="-3,-8,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
       </StackPanel>

       <!--ContentPanel - place additional content here-->
       <Grid x:Name="ContentGrid" Grid.Row="1">
           <Button Content="Greetings !" Margin="128,252,116,254" RenderTransformOrigin="0.5,0.5" Opacity="0.995" CacheMode="BitmapCache" Click="Button_Click">
               <Button.RenderTransform>
                   <CompositeTransform Rotation="-0.271"/>
               </Button.RenderTransform>
           </Button>
       </Grid>

C# Code :

using System.Windows;
using Microsoft.Phone.Controls;

namespace Demo_Hello_World
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            // TODO: Add event handler implementation here.
            MessageBox.Show("Welcome to world of Windows Phone 7","Windows Phone 7 Console",MessageBoxButton.OK);
        }
    }
}

I know this is very very basic example but don’t worry advance examples are coming from right next week, Till that time get comfortable with Tools and IDE, See you next week with some more exciting applications of Silverlight for Windows Phone 7

Vikram.

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • First Windows Phone 7 update February 2011 - Small update but Big start
    After tons of rumors and set of predictions on Windows Phone 7 all over Internet, Microsoft came up with first Windows Phone 7 minor update ...
  • The little Story of “I Unlock Joy” event by Microsoft and Pune User Group
      This post is about recent “I Unlock Joy” event happened in Pune which was conducted by Microsoft and Pune User Group. Little History : ...
  • Silverlight On Mobile : Windows Phone 7 Splash Screen and Customization
    After talking about 3D capabilities on Windows Phone 7 using Silverlight in last article , Now I am moving ahead with small but equally impo...
  • Silverlight 5 : Platform Invoke (PInvoke) in Silverlight
      Two days back Microsoft announced availability of Silverlight 5 RC,I encourage you to download bits from here , My friend Pete Brown alr...
  • Introduction to Speech Capabilities in Windows Phone 8 – Part 1
    After a long..I am writing blog, I hope and I wish I will resume blogging like I use to in past. Lots of things happened in past few months....
  • MCTS : Microsoft Silverlight 4 Development Exam Guide (70-506) by Packt Publishing
      Hello, After a long time I got chance to come back here.I will soon resume blogging in month of August. Last 4-5 months were horrible due...
  • Introduction to Speech Capabilities in Windows Phone 8 – Part 2
    Hope you enjoyed my last article on Speech Capability in Windows Phone 8, Today I am posting another part or you can say little extension t...
  • Silverlight 3 : Insert & Update Data using WCF Service with DataForm and DataGrid
    In my Lap around Silverlight 3 series, I have written a separate article on DataForm in Silverlight 3, This article is a basic extension to ...
  • Mango : Using DeviceStatus in Windows Phone 7.1
    First of all “Thank You” for your wonderful response and comments on my last article on Silverlight Vs HTML5 ,I hope you like the points I ...
  • Silverlight, HTML5 & Windows 8 : Where we are heading to ?
    This is not the post or yet another post on most happening debate of Silverlight and HTML5, This is just a visit to all of them to realize t...

Blog Archive

  • ►  2013 (4)
    • ►  August (1)
    • ►  April (3)
  • ►  2012 (4)
    • ►  July (1)
    • ►  March (2)
    • ►  January (1)
  • ►  2011 (24)
    • ►  December (1)
    • ►  September (4)
    • ►  August (2)
    • ►  July (1)
    • ►  June (4)
    • ►  May (3)
    • ►  April (3)
    • ►  March (1)
    • ►  February (4)
    • ►  January (1)
  • ▼  2010 (21)
    • ►  December (1)
    • ►  November (2)
    • ►  October (3)
    • ►  September (2)
    • ►  August (4)
    • ▼  July (5)
      • Silverlight On Mobile : 3D on your Windows Phone 7...
      • Silverlight on Mobile : Write your first Windows P...
      • Silverlight on Mobile : Get Ready with the Tools a...
      • Silverlight on Mobile : Getting started
      • I am Silverlight MVP
    • ►  May (1)
    • ►  April (1)
    • ►  March (1)
    • ►  January (1)
  • ►  2009 (49)
    • ►  December (1)
    • ►  November (5)
    • ►  October (2)
    • ►  September (1)
    • ►  August (5)
    • ►  July (5)
    • ►  June (1)
    • ►  May (5)
    • ►  April (5)
    • ►  March (9)
    • ►  February (4)
    • ►  January (6)
  • ►  2008 (43)
    • ►  December (3)
    • ►  November (9)
    • ►  October (7)
    • ►  September (4)
    • ►  August (2)
    • ►  July (3)
    • ►  June (4)
    • ►  May (3)
    • ►  March (3)
    • ►  February (5)
Powered by Blogger.

About Me

Unknown
View my complete profile