Category Archives: Tips

Update to my Trial Mode post

So I just release an app to the marketplace recently. (Check it out here http://underbridgecity.net/underbridgegraffiti/) And I implemented the trial code I mentioned in my Trial Mode post (http://www.underbridgecity.net/blog/2012/03/trial-mode-in-windows-phone-7/) so that when you bought the app and then pressed the back button you should be in full mode and not trial.
I tested it out, and it worked! I went into the app, clicked a button to go to the marketplace to buy it, bought it, went back… and I had to press back an extra time but then went back into the settings page and the app no longer was in trial mode.

So if you implement trial mode, I suggest adding in the check if trial or not in the application activated section to always check when you navigate to the app no matter how you get there.

I will upload a video soon of me buying it.

Multitouch in WP7

I just published an app. (You can check it out here http://underbridgecity.net/underbridgegraffiti/.) Has the ability to allow more then one finger to interact with the screen at one time. Here is how I was able to set it up on a canvas which is set up in the xaml.

So to get multitouch set up I used a TouchFrameEventhandler. You will have to add

as a reference and a using statment.

I created a class called DrawingPoints and then created a list collection of them.

Read more »

Different Templates in one Listbox

In this post I will explain how I selected different templates based on the type of data I wanted to show in the same listbox.

Now why might you want 2 different templates in the same list box? Well what if you wanted to display different tasks and appointments for a single day. But you want to see at a quick glance what a task is and what an appointment is. So lets say you have a square for all tasks and a circle for all appointments.

To do this you will use a ContentControl which as the data gets bound to the listbox, we will override the method to check if the item getting bound is a task or appointment. And then set the template depending on what it is.

In my code example the tasks and appointments both inherit from a class called CalendarItem. This is an object orientated programing principle, and if you don’t understand it let me know and I will create a blog about the basics of it.

Read more »

Overwrite WP7 Style Theme

I was working on a Windows Phone 7 application and the client wanted to always have the light theme and have a special accent color depending on settings inside the app. They wanted to do this for branding reasons so I had to find a way to always have this app look like it was in the light theme and override the accent color to the colors they wanted.

I will now go over how I did that. You can use this to always have the light theme for the app like the native mail app, or even create your own custom theme.

In the code I created a method in the App.xaml.cs file, and this method get called in the constructor for App() before the InitializePhoneApplication() call.

You will also need to set teh background on all the pages to {StaticResource PhoneBackgroundBrush} like

I tried to document the code so you can understand what is going on line by line so I will give a little explanation here.

The line

loads the theme you are going override. Here I copied a default theme resource file (Edit: the theme resource file is ThemeResource.xaml) from the design folder located on my machine at C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Design\LightBlue and called it LightTheme.xaml. If you look in the design folder you will see many folders.

Then the code went though all the entries and compared the ResourceDictionaries, if the custom theme file contains the key name of a main style element, it will overwrite it’s brushcolor. If you look at a default theme resource file, it contains a bunch of colors with keys and the keys are pretty self explanatory. So if you wanted to create your own custom theme you can start by copying and editing one of those files.

Also in my code you see me checking a setting value and then overriding the accent color depending and the user setting. This isn’t required unless you want the user to select a special accent colors in the settings or want them to change, if you just want one over ridden accent color just put it into your style resource file.

And questions or comments just let me know and thank you for reading.

Trial Mode in Windows Phone 7

While building my apps for WP7 that users will pay for, I like to create a trial so the users can try out my app before they buy it. But when you are debugging your app there is no Trial simulation. So Looking on the web I found one.

Here is what i do to simulate trial mode in my Windows Phone 7 apps.

First at the top of your App.xaml.cs file add this

*EDIT*
I forgot to put this in here at the top. You need it to access the licence information.

and to use that you will need to add in the folling using statment.

*END EDIT*

I usually add that in right under my RootFrame property.

I then create a method in my App.xaml.cs

I then put the CheckLicence method into my Application_Launching and Application_Activated methods in my App.xaml.cs file to check if the application is bought or a trial version.

Then in your code you set up what will happen in your trial version and all you have to is check the IsTrial if true, it is a trail version. If false it is a full/paid version.

I hope this helps you out creating your WP7 app!

(EDIT: Putting this code in will check if trial or not after you buy the app, check out my post here http://www.underbridgecity.net/blog/2012/04/update-to-my-trial-mode-post/)