DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
11 Monitoring and Observability Tools for 2023
Learn more

A Simple Calculator App for Windows Phone in 10-15 Minutes

Paresh  Mayani user avatar by
Paresh Mayani
·
Mar. 27, 12 · Interview
Like (0)
Save
Tweet
Share
8.73K Views

Join the DZone community and get the full member experience.

Join For Free
Being an android developer, I was trying to find out which platform will be the most exciting to learn next, and I have found myself starting with WP7 instead of BlackBerry because WP7 provides more flexibility than BlackBerry app development. FYI, I have also tried to develop basic examples in BlackBerry but it requires a lot to implement this simple Calculator example, where as here I was able to create this example in 10-15 minutes.

Here is a solution for a Simple Calculator example:

Output:

 


Main.xaml

<phone:phoneapplicationpage x:class="PhoneApp1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d" d:designwidth="480" d:designheight="768" fontfamily="{StaticResource PhoneFontFamilyNormal}" fontsize="{StaticResource PhoneFontSizeNormal}" foreground="{StaticResource PhoneForegroundBrush}" supportedorientations="Portrait" orientation="Portrait" shell:systemtray.isvisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <grid x:name="LayoutRoot" background="Transparent">
        <grid.rowdefinitions>
            <rowdefinition height="Auto">
            <rowdefinition height="*">
        </rowdefinition></rowdefinition></grid.rowdefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <stackpanel x:name="TitlePanel" grid.row="0" margin="12,17,0,28">
            <textblock x:name="wp7example1" text="Windows Phone 7 Example - 1" style="{StaticResource PhoneTextNormalStyle}">
            <textblock x:name="pageName" text="Simple Calculator" margin="5,-7,0,0" style="{StaticResource PhoneTextTitle1Style}" fontsize="30">
        </textblock></textblock></stackpanel>

        <!--ContentPanel - place additional content here-->
        <grid x:name="ContentPanel" grid.row="1" margin="12,0,12,0">
            <button content="Calculate Sum" height="72" horizontalalignment="Left" margin="111,386,0,0" name="button1" verticalalignment="Top" width="221" click="button1_Click">
            <textblock height="30" horizontalalignment="Left" margin="20,22,0,0" name="textBlock1" text="Enter First No:" verticalalignment="Top">
            <textbox height="72" horizontalalignment="Left" margin="12,58,0,0" name="txtFirstNo" text="" verticalalignment="Top" width="420" inputscope="Number">
            </textbox>
            <textblock height="30" horizontalalignment="Left" margin="20,152,0,0" name="textBlock2" text="Enter Second No:" verticalalignment="Top">
            <textbox height="72" horizontalalignment="Left" margin="12,188,0,0" name="txtSecondNo" text="" verticalalignment="Top" width="420" inputscope="Number">
            <textblock height="30" horizontalalignment="Left" margin="20,272,0,0" name="textBlock3" text="Result:" verticalalignment="Top">
            <textbox height="72" horizontalalignment="Left" margin="12,308,0,0" name="txtResult" text="" verticalalignment="Top" width="420">
            <border borderbrush="Silver" borderthickness="1" height="466" horizontalalignment="Left" margin="5,6,0,0" name="border1" verticalalignment="Top" width="451">
        
    
 
</border></textbox></textblock></textbox></textblock></textblock></button></grid></grid></phone:phoneapplicationpage>

Code for button click event:

private void button1_Click(object sender, RoutedEventArgs e)
      {
          txtResult.Text = Convert.ToString(Convert.ToInt32(txtFirstNo.Text) + Convert.ToInt32(txtSecondNo.Text));
      }


What do you think? Pretty cool, isn’t it?  :)




Windows Phone app Calculator (Mac OS)

Published at DZone with permission of Paresh Mayani. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Building a RESTful API With AWS Lambda and Express
  • An End-to-End Guide to Vue.js Testing
  • DevSecOps: The Future of Secure Software Development
  • Shift-Left: A Developer's Pipe(line) Dream?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: