If I can build a phone app anyone can: Changing the keyboard and IsNumeric


    In todays blog I start coding my app, the first task is having users enter a time for my timer and making sure they enter a number. So I explore adding code to make sure they enter a number, and changing the on screen keyboard to show just numbers.

    Wow I’ve been spending a lot of time learning about the projects, tools, and controls, it’s great that I am finally starting to code! If you missed any earlier posts you can find them here. My application will be a presentation timer that I can use to make sure I don’t talk too long.

    I’ve created a New project of type Windows Phone Application in Visual C# (by the way as I start to code if you can make any of my code more elegant, feel free to leave comments, I am open to suggestions and improvements).

    When I created my project I chose target Windows Phone OS 7.1 (which is the same as 7.5 which is the same as Mango) because at this point most Windows Phone users have Mango and I want to be able to use the latest features.

    Adding validation code

    I need a text box where a user can enter the number of hours, minutes, or seconds for the timer. So I’ll just drag a TextBox control to my page. I change the name of the TextBox to txtHours and set the Text to a value of 1, this will be the default value. When I run the app and click in the TextBox it looks like this.


    I don’t want users entering letters, so I had better add some validation to make sure the users enters numbers in the TextBox and i will add a TextBlock for displaying an error message to the user.

    I create a TextBlock control and name it blkMessage and set the Foreground property to Red and the Text property to an empty string.

    Now I double click on the my TextBox control which takes me to the code page and creates a TextChanged event handler for me. The TextChanged event handler fires whenever a user changes the content of my TextBox, so it literally fires every time you type in a letter or number (that means I don’t want too much code in there because it wouldn’t be great for performance). In my event handler I test to see if the value in the text box is numeric, if it isn’t, I display an error message. If it is a valid value, I clear out the error message. My code looks like this. BUT IsNumeric is a function I had to add myself it is not built in! I got the code for the IsNumeric function from this blog post (thank you Keith Murray)

            private void txtHours_TextChanged(object sender, TextChangedEventArgs e)
                if (!IsNumeric(txtHours.Text))
                    blkMessage.Text = "You must enter numbers only";
                    blkMessage.Text = "";

    Now if a user enters letters or other non numeric values in the field they see an error message like this:


    Changing the on screen keyboard

    That works, but I don’t like the way the keypad comes us as letters as default which could be a bit annoying. With mobile apps you really want the user to have to use the keyboard as little as possible, so every keyboard tap I can save the user is a good thing. In addition, it’s good design to stop someone from entering an invalid value in the first place wherever possible, if I display a numeric keypad I don’t need to worry about someone entering letters and symbols! A quick bing search turns up a blog post that talks about setting the InputScope to get the numeric keyboard. Sounds worth a try. Unfortunately I can’t find a way to set that value in the property page so I am going to have to edit the XAML, and of course the XAML example in the blog post doesn’t work, but a quick search on MSDN for InputScope gives me the correct syntax.

    So I have to open up the XAML pane by clicking on the little arrow button in the corner

    imageThen find the <TextBox …/> called txtHours and add the InputScope attribute and set it to Number (wow I didn’t think I’d be messing in the XAML code this soon! but this really wasn’t that scary)

            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <TextBox InputScope="Number" 

    And now when I run the application in the emulator, check it out: just numbers! Much better for my user!


    So now I just need to replicate that logic for my hours, minutes and seconds textboxes. It’s fun to be starting my application. We’ll see what I learn next. Hope you are making progress with your apps as well. Remember if you publish an application by May 20th, 2012 you can get cool stuff thanks to the developer movement so get coding!

  • Go DevMENTAL

    Winning on the Marketplace: Where in the world are you publishing?


    If you’ve built modern mobile apps, you probably already know that coming up with the idea for the app/game and coding it is really only half the battle.  Success is largely determined in the marketing strategy you adopt for your app.  There are quite a few strategies that you can take and you can likely mix and match them, but there is no one “silver bullet” that will make your app an instant success.  This post is the first in a series of five that will give you an idea of some of the ways you can help your app become a success in the Windows Phone Marketplace.

    toughThere’s a statistic that was published by analytics vendor Localytics that states that only 26% of all mobile apps downloaded are ever opened more than once.  That’s actually a little higher than the numbers I’ve heard around mobile app circles, but still that number is quite astounding.  What it means is that for a myriad of reasons, most users are interested enough to open your app but quickly lose interest and either delete right away or never open it again.  Those odds are not good, so if you intend for your app to be popular, you need to adopt a strategy that will give you an edge and compel your user base to make use of your app more than once.

    There are multiple things you need to do before your app is ready for consumption.  One is to have a great idea (this is pretty much non-negotiable in my opinion).  Second, you need to build it the right way (i.e.:  great functionality, application flow, pleasant interface and intuitive app design). Third, you need to figure out a way for your app to make your users awesome in the moment.  All this before your very first user even thinks of downloading your app. 

    At the same time as building your app, you should be thinking about how you’ll market it once it’s ready.  Over the next 5 days, I’ll be posting an entry per day discussing some of the strategies you can employ to help make your app or game more successful on the Windows Phone Marketplace.

    Making your apps available on as many markets that make sense to support, not ALL markets possible

    The context of this first post is about understanding which geographies you can make your app available in.  Your first answer to “which countries should your app be available in?” might be “All of them, of course!”, but keep in mind a few things.  The correct answer to this question is that you should assess which countries your app will have value to users and how you will be able to support those users with your app.

    For example, there is a fantastic app called “Where’s Timmy?” that RedBit Development created and published that is a consistently popular one in Canada.  While there is nothing that limited Redbit from making the app available in every single market, the purpose of the app is to locate the closest Tim Horton’s coffee shop from your location.  Tim Horton’s is very popular in Canada and growing in popularity in the US, but has no presence in Europe.  As a result, Redbit did not publish the app in European countries but did publish it in Canada and the US.

    Another consideration to take into account is localization.  Making your app available in many markets may require you to support many different languages for your apps.  You must make a judgment call as to which languages you wish to support.  While this adds to the complexity of your app from a maintainability perspective, it enhances the local user’s experience while using the app.  By localizing the content of your app to the appropriate language and culture considerations, you will likely have better adoption and better ratings for your app in the Marketplace.

    Markets Supported by Windows Phone

    So with that said, what markets are currently supported by Windows Phone?  The graphic below shows which markets are supported (countries highlighted in yellow are markets that have been supported since launch in November, 2010 while markets highlighted in green were added just recently).



    Marketplace distribution and targeting the right locales is one of the strategies for being successful in the Windows Phone Marketplace.  Stay tuned for further Marketplace strategies over the next few posts on the Canadian Mobile Developer Connection, where I’ll talk about the trial API, pricing strategies, differentiation using Windows Phone-specific features like Live Tiles and Push Notifications and finally, how you can get promoted in the Windows Phone Marketplace.

    This post is the first in a series of five posts on strategies for being successful on the Windows Phone Marketplace.  The second post (trial mode and the art of the upsell) is here.  The third post (pricing strategies), fourth post (differentiation using Windows Phone-specific features like Live Tiles and Push Notifications) and fifth post (how to get promoted in the Windows Phone Marketplace) are upcoming on this blog.

  • Go DevMENTAL

    Come see us at CUSEC!


    We are at CUSEC in Montreal!

    The Developer Evangelist team is very excited to be attending the Canadian University Software Engineering Conference 2012 in Montreal. After hearing a lot of good things about CUSEC 2011 from our teammates, we started counting the days until it started.

    The speaker lineup is amazing, the event schedule is great and don't forget this is the perfect opportunity to have some of that mouth-watering poutine everyone keeps talking about!

    This year's keynotes are quite impressive. Ranging from Reddit Co-Founder, serial entrepreneur and angel investor Alexis Ohanian talk; all the way to a presentation on the now omnipresent Facebook like button by Facebook engineer Andrew Rothbart. Don’t forget there is just as much geek goodness throughout all the keynotes as you can imagine.

    Our own Susan Ibach will be among the speakers. She will be giving a tutorial on how simple it is to build your own windows Phone 7 app.

    After you have applied for jobs at the career fair, make sure you head over to this tutorial. It will be worth your while. Especially for the rewards you get for building the apps!

    We hope to see you at our Microsoft booth in between keynotes. You will be able to play some Xbox, try the Kinect, find out about Imagine Cup,  take those elusive windows phones for a test drive and submit your CV for a chance to be part of Microsoft and guide the next tech revolution!

    Oscar Guerrero | Academic Developer Evangelist

  • Go DevMENTAL

    My love affair with Visual Studio: Error Correction


    I have been working with Visual Studio for years, and I’ve found a few tricks along the way that make my coding easier. In this blog post I’ll show one of my favourite time savers the Error Correction feature.

    When you are writing code for a form or a class as part of a team, or even if you are just starting work on a project which will be made up of multiple classes, you always end up having to reference classes, properties, or methods in your code that haven’t been written yet. So you either have to comment out those calls, add them later, or add stubs so your code will compile. In Visual Studio 2010 they added a neat little feature that will add the stubs for you!

    Say I am writing code for a click event handler that will create and populate an instance of a Student object who will be registering for a course. I haven’t created the Student class yet so I see a squiggly under the word student and this little rectangle at the end of the squiggly.


    Now comes the cool part, I can carefully hover the mouse over the tiny rectangle and a little warning symbol will appear, if I hover just right it will appear with an arrow beside it that I can click on.


    Clicking on that little arrow will bring up a menu of options that will fix the error for me! By the way, if like me, you find using the mouse to bring up the list fiddly, you can use the keyboard to bring up the correction menu by putting the cursor on the word student and hitting CTRL + . that’s CONTROL KEY and a PERIOD.


    Visual Studio is offering to create a Student class for me, or to define a new type (variable essentially). If I click on Generate ‘Class Student’ I can see a new class appear in Solution Explorer called Student.vb


    If I open up the Student class I see it has not only created a class, but because my code called a constructor and passed in two variables, it created a constructor method in the class as well that accepts two variables!


    The code isn’t complete by any means, but it’s enough to get rid of the squiggly on Student in my event handler!


    Of course now I have squiggly lines under vFirstName and vLastName because I haven’t declared those yet, but if I bring up the Error Correction list for those variables I select Generate field for vFirstName and then Generate field for vLastName and it adds the declarations for me!


    Sure, it didn't’ know what data type to make the variables, it’s not perfect, but when I am trying to test something quickly these little Error Correction tools that will generate code stubs for me can be a real time-saver.

    This blog also appears on the Canadian Solution Developer Blog

  • Go DevMENTAL

    Tips and Tricks from students: Windows Phone Game “Tile Tank”



    3 students from Carleton share what they learned building their first Windows Phone Game

    Check out more tips from fellow students here

    TileTank-TeamPhoto-CroppedCould you briefly describe your application/game?
    Tile Tank is a puzzle game, and it’s all about finding a viable path across a variety of obstacle courses. Your job is to drive around the maze collecting all the gears, then make your way to the goal flag. The mechanics are simple but it’s the puzzles themselves that will amuse, challenge, and maybe even stump you.
    Plus, when you’re done with the campaign, you can create your own levels and share them, or download levels that other players have shared! 

    Did you use XNA, Silverlight or both?
    When we heard about the way we could use both, we knew it suited our needs. The game is entirely displayed on Silverlight pages, including the menus, the game view, and the GUI. The 3D graphics in the game view are drawn by XNA. Silverlight was great for putting together 2D interfaces with buttons and forms, while XNA covered our needs for a 3D world.
    It was interesting to learn how both these modes are run within the same kind of XNA application page. It seems like a really flexible way of going about it and we’ll probably do it again in future projects.

    What was your banging your head against a wall moment?
    Because it was a learning project, we had a few minor technical issues. One of them was an issue where our Silverlight buttons would turn to a white rectangle (no image) for a moment when touched. We didn’t know how to mask this for a while.

    Did you ever solve that issue?
    Yep, we found a solution/workaround using custom styles for Silverlight. Just took a bit of digging. And we’re still not sure if you can get a button “down” state - though not many other apps use this anyway.

    If you had to build this same app again from scratch, what would you do differently?
    This was our first real endeavor in XNA so it was mostly about all the little learning experiences, so it’s tough to pick something that stands out to be corrected. If we did start over I think we’d go in with a better feel for how to manage ourselves and our project files. By the end, the build was pretty cluttered.

    Any nice suprises?
    Something that was very welcome was how easy it was to get started with development. Getting the SDK and the environment set up was no real hassle, and there are basically no major hurdles before you can start building and testing. Then, after looking at a few beginner examples, we had the building blocks of a good portion of our app. The included emulator for Windows Phone makes testing very convenient.

    Did you leverage the mobile platform?
    We knew from the start that mobile was where we wanted to be, and we tailored our concept and design to that the whole time. We made sure to look at a lot of existing apps to see what we liked and didn’t like about how they do things. Available screen size and the kind of interactions a phone user expects has to be constantly on your mind when thinking about layout and the level of attention to detail throughout your app.
    We think Tile Tank definitely plays best on the phone because the control is simple and it’s something you can tinker with easily for a couple minutes at a time while you’re on the go.

    Did you leverage the touch screen?
    Most of our touch controls could be translated to mouse but it’s definitely most intuitive and the most fun with the basic touch gestures of tap, swipe and pinch. The way that touch gestures are processed by the app also made it pretty simple to get the controls to be smooth.

    Did you have a favourite feature?
    It’s a subtle feature, but we leverage the ability to make HTTP requests directly from the app. Combined with some PHP, this gives us the ability to look at a database to upload and download levels. Also, your progress is actually tracked and scored while you play, and you can show up on a scoreboard on the game’s website. In play tests we’ve already had some players get pretty determined to make it to the top of the board. As a developer, that kind of enthusiasm is extremely rewarding, even in small tests.

    What is one thing you think you did really well in this application?
    At the outset, we put a lot of thought into the scope and feature set of this game, and we gave everything a priority value. We did drop a couple of things, but because we planned in this way, they were pretty non-essential and we did get all the important features we wanted. We were really pleased about that in the end, especially considering the uncertainty of factoring in research and learning time.

    Are you publishing your application/game?
    Yes, Tile Tank is available right here on on the Windows Phone Marketplace. It is free!

    Where can I learn more about your app/game?  
    tiletank.com and our Facebook page “Tile Tank” are the places to watch for videos, high scores and other new stuff.

    Who developed this application?
    Our team is Kevin Paquette, Chris Atallah and Chris Burt. We’re classmates at Carleton University’s School of Information Technology, studying Interactive Multimedia and Design. It’s a mouthful, but it boils down to getting a working understanding of a ton of different technologies and design methods. Tile Tank was among our latest efforts in course work for game development, as well as project management.

    Making the game definitely brought us together and gave us inspiration to really look at where our skills could take us in indie marketplaces like Windows Phone. It was a school project, but it never really felt like it, although we certainly appreciate the support and enthusiasm of our professors. Everything we did for this game was mainly to accomplish something for ourselves and we learned a lot about something we really wanted to know more about.

Page 55 of 82 (409 items) «5354555657»