• Changing you Application Title in Windows Phone 7

    by Venkata Koppaka | Nov 21, 2010

    This is another quick post in which I will show you how to change Application Title in Windows Phone 7 Application List.

    Here is how the "Save the world Ninja!" app title is looking right now (If you haven't had a chance to read the post I did on how to create the Save the world Ninja! app I would suggest that you do here.) 

    Now I want to change this title to something more meaningful.

    To change the title of your app in Windows Phone 7 App list, open up WMAppManifest.xml file in the properties folder of your Windows Phone 7 Project.

    In the WMAppManfiest.xml file you will find a node called "App" and change change that line to be something like this

    1 <App xmlns="" ProductID="{97a383c7-abb9-40ec-839d-0ac3aa168ccb}" Title="Save the World, Ninja!" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal"  Author="Venkata Koppaka" Description="Save your world Ninja!" Publisher="Venkata Koppaka"> 

    Note the title in the above XML has been changed to "Save the World, Ninja!". I actually changed the Application icon the Windows Phone 7 App shows, here is how you would put your own  icon.

    1 <IconPath IsRelative="true" IsResource="false">ninja.png</IconPath> 

    And now if I run my App this is how it would look like -

    If you wish to checkout the updated code, its checked in to GitHub here -https://github.com/subbaraokv/Hello-World---Windows-Phone-7

    Hope this helped,

    Cheers,

    Venkata

    Go comment!
  • Bringing up Software Keyboard in Windows Phone 7

    by Venkata Koppaka | Nov 20, 2010

    This post is short and quick one, in the previous post I created a Hello World Windows Phone 7 App. If you haven't read that already please do so here.

    In this post I will just add a small functionality to the app. I wanted the software keyboard on the Windows Phone 7 device to come up as soon as the App loads.

    Generally the software keyboard in Windows Phone 7 automatically pops up whenever a textbox control has a focus on the phone, but I since my Ninja App only had one textbox it makes sense to automatically bring up the software keyboard as soon as the app loads so the user can start typing in right away.

    Here is how you would do it. There is a "PhoneApplicationPage_Loaded" event that gets fired on the app load.

    So all you have to do is to set the focus on a textbox in the loaded event and the software keyboard will automatically showup. 

    Here is the code sample for doing so -

    1 private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) 
    2         { 
    3             tbNinjaPhrase.Focus(); 
    4         } 
    That's it.

    If you wish to checkout the updated code, its checked in to GitHub here -https://github.com/subbaraokv/Hello-World---Windows-Phone-7.

    Hope this helped,

    Cheers,

    Venkata


    Go comment!
  • Building Hello World! Windows Phone 7 App

    by Venkata Koppaka | Nov 19, 2010

    In this post I will walk you through on how to build a Hello World Windows Phone 7 App. The "Hello World" app that I am building in this tutorial is a "Save the World" app in which if you enter a correct pass phrase you will save the world for you :), if not you cannot save the world :P

    To get started you will need Windows Phone 7 Developer Tools, you can download them here.

    Once you download and install Windows Phone 7 Developer Tools, Create a Windows Phone Application.

    You will be presented with a dialog which would look like this -

    The first thing I did after creating the app is to rename Application Title and Page Title. Here is what I renamed them to

    1 <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> 
    2             <TextBlock x:Name="ApplicationTitle" Text="My Ninja App" Style="{StaticResource PhoneTextNormalStyle}"/> 
    3             <TextBlock x:Name="PageTitle" Text="Save the world" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> 
    4         </StackPanel> 

    And this is what the Phone Emulator looked after I renamed -

    I will now drag couple of textblocks, a textbox and a button on to the Phone designer and then rename them to something which makes more sense, here is the XAML -

    1      <TextBox Height="72" HorizontalAlignment="Left" Margin="12,116,0,0" Name="tbNinjaPhrase" Text="" VerticalAlignment="Top" Width="460" /> 
    2             <TextBlock Height="79" HorizontalAlignment="Left" Margin="25,31,0,0" Name="textBlock1" Text="What is your Ninja pass phrase to save the world?" VerticalAlignment="Top" Width="425" TextWrapping="Wrap" /> 
    3             <Button Content="Save the World!" Height="69" HorizontalAlignment="Left" Margin="109,194,0,0" Name="btnSaveTheWorld" VerticalAlignment="Top" Width="249" Click="btnSaveTheWorld_Click" /> 
    4             <TextBlock Height="114" HorizontalAlignment="Left" Margin="25,269,0,0" Name="messageBlock" Text="" VerticalAlignment="Top" Width="425" TextWrapping="Wrap" /> 

    and this is how the phone UI will look like after dragging all the UI elements -

    Then I double click on button and put in this code in the code behind -

    1 private void btnSaveTheWorld_Click(object sender, RoutedEventArgs e) 
    2         { 
    3             string ninjaPhrase = tbNinjaPhrase.Text; 
    4             if (!string.IsNullOrEmpty(ninjaPhrase)) 
    5             { 
    6                 if (string.Compare("startrek", ninjaPhrase, StringComparison.OrdinalIgnoreCase) == 0) 
    7                 { 
    8                     messageBlock.Text = "Vola! Way to go Ninja, You saved the world!"; 
    9                 } 
    10                 else 
    11                 { 
    12                     messageBlock.Text = "That is not a Ninja Phrase! You cannot save the world!"; 
    13                 } 
    14             } 
    15             else 
    16             { 
    17                 messageBlock.Text = "Are you kidding? That is not a Ninja Phrase! You cannot save the world!"; 
    18             } 
    19         } 
    I run the App and vola!,

    Here is what you would see when you put it "stratrek" as pass code :)

    And if you put in some other pass phrase you would see "You didn't save the world" :)

    And that is your first Hello World Windows Phone 7 App.

    If you wish to checkout the code here is the code on GitHub https://github.com/subbaraokv/Hello-World---Windows-Phone-7

    Hope this helped,

    Cheers,

    Venkata

    Go comment!