MDC Code Samples Posted

10/18/2011 12:05:13 PM

Finally go around to posting the code samples.  You can find the links to the presentations here.

Mango

Silverlight 5

Tags:

Silverlight | Windows Phone

MDC Presentations

10/7/2011 9:43:04 AM

The slide decks for my MDC11 presentations can now be downloaded from the slideshare.net site or from the links below…

What’s New in Windows Phone 7.5 (Mango)

What’s New in Silverlight 5

Tags:

Silverlight | Windows Phone

New WP7 App in the Marketplace

6/24/2011 8:11:36 AM

TimeRunning-small landscapeI was able to put the new Windows Phone 7.1 “Mango” tools through their paces and finally got an app I had wanted to write for a while into the marketplace.  Taxi Meter is an app that let’s you “play taxi” and charge based on things like time, distance, etc.  It wasn’t a complicated app to write, but I had been putting it off for a while because it made heavy use of the GPS and working with the GPS in the “old” tools was a pain.

The new Mango tools, with the Location emulator, made it a snap!  Impressive and very easy to use.  I haven’t had a chance to play with the Accelerometer emulator yet, but it appears to be just as easy based on the demos I have seen.  WP7 has the best dev tools on the planet!

Tags:

Windows Phone | Headlines

Message Based Navigation for WP7 MVVM Apps

4/26/2011 8:30:00 AM

Do you have an MVVM-based Windows Phone 7 application and you don't like having to hook into the RootFrame to navigate between pages? Do you wish you could just "ask" to navigate to a new view from your view model? One possible solution can be found in my new Channel 9 screencast.

Using an message bus to process navigation messages, view models can publish messages that are then handled by a separate navigation service, successfully decoupling your view model from the Windows Phone navigation service.

Get the finished source code here

Tags:

Blend | Windows Phone | Screencasts | MVVM

MultiScreen Development with Microsoft Technologies Content Available

1/13/2011 1:21:56 PM

Here are links to the slides and demo code to the Multiscreen Development with Microsoft technologies webcast I did today. Look for some Channl9 videos starting soon that will go through the different parts in more detail.

PresentationDemo Code

Tags:

Headlines | Windows Phone | XAML

Twin Cities Silverlight User Group Presentation: Panorama, Pivot and Map Controls

9/21/2010 10:33:09 AM

Here is the slide deck from my presentation today at the TCSLUG.  Plenty of examples on working with this stuff in the WP7 Training Kit, so no source code.

Tags:

Windows Phone

How Far to THE DROVER?

9/14/2010 3:18:00 PM

droverAt HDC 10, I had the opportunity to eat at THE DROVER in Omaha, NE.  If you are not familiar with THE DROVER (capital spelling due to required emphasis on the name of the restaurant), it is simply the WORLD’s BEST steakhouse on the face of the planet.  I used to live in Omaha and discovered THE DROVER almost twenty years ago.  There is simply no comparison or description worthy of THE DROVER.  It is one of a kind. 

I had the good fortune of eating at THE DROVER two nights in a row when I was in town for HDC.  It was perhaps the two most fulfilling nights of my life.  I feel a warmth in my belly at the mere thought of THE DROVER, yet I also feel a certain sadness.  Why?  Because I am now far away from THE DROVER.  But how far away am I?  How many miles of unforgiving, whiskey fillet empty sadness and despair stand between me and THE DROVER? 

Fortunately, Windows Phone 7 and Silverlight can easily provide me the answer.  I present to you, the FIND THE DROVER application.  This app brings me solace during the day just knowing that THE DROVER still exists.  That while I may be many miles away, there is still a whiskey fillet being ever so lovingly grilled to perfection on iron grates.  That some day, I will once again travel the barren wastelands between THE DROVER and I, and once again enjoy the “heaven on earth” that is THE DROVER.

Make sure to look for FIND THE DROVER in the Windows Phone Marketplace in the near future.

Tags:

Junk | Windows Phone

Windows Phone 7 Launch Event Coming to Minneapolis

9/14/2010 9:45:15 AM

On Oct 5th and 6th, the official Windows Phone 7 Launch event will be held in downtown Minneapolis.  This is a two day event.  Day One is the traditional, presentation/demo style event that we all know and love.  Day Two, however, is a “space is limited” Hands-On workshop event.  You can register for the event here.  Registration for Day Two can be found at the bottom of that page or go sign-up directly here.

Hope to see you there!

Tags:

Headlines | Windows Phone

Need to Determine the Current Theme on Windows Phone 7

9/14/2010 9:01:30 AM

I was asked at HDC10 about detecting the current theme on #WP7. There isn't an API to do so, but there is a solution.  Check out this article for a nifty work-around.

Tags:

Windows Phone

Managing Trial Applications for Windows Phone 7

8/30/2010 11:53:00 AM

(Download Source Code)

(Video Walk-Through)

Windows Phone 7 provides the LicenseInformation class that includes the IsTrial() method.  IsTrial() allows you to check, at runtime, if the running application has been installed from the Marketplace as a trial application, or if the user has purchased the application.  Developers are able to use IsTrial() to change the behavior of their application based on whether or not the user is running a trial version or a paid for version.  Unfortunately for WP7 devs, there is no easy way to control the IsTrial() results when developing and debugging their applications. IsTrial() will always return False when developing an application.  Even more disappointing, LicenseInformation is a sealed class and there is no ILicenseInfo interface that you could use to mock out your own implementation while developing.

In addition, each developer is left to his or her own devices to come up with a system for controlling how their trial software behaves.  Simple things like turning of features in the trial version is pretty straightforward, but if you want to have a more complex behavior, things get trickier.  What if you want someone to be able to use your application for 30 days before you disable features?  How about 10 uses of the application before they need to buy the full version?  You are on your own.

TrialManager is a simple piece of code that you can add to any WP7 project to help manage the behavior of your trial apps.  TrialManager will also make it easier to simulate you application running in Trial mode when creating your apps.  You can get the source to TrialManager here.  Feel free to use it, modify, etc.  The only licensing restriction is that I ask you send me an email letting me know you are using the code in some form or fashion.

Setting Up TrialManager for Usage Tracking

To get start with TrialManager, just at the SlickThought.Phone.dll to your Windows Phone project.  After that, the first thing you need to do is modify your App.xaml file to instantiate TrialManager each time your application runs.  The nice thing about TrialManager is that all of its behavior is configured using App.xaml.  Here are the changes you would need to make in your app to get started…

    xmlns:trial="clr-namespace:SlickThought.Phone;assembly=SlickThought.Phone"

Next, we modify the Application.ApplicationLifetimeObjects element as shown below:

    <Application.ApplicationLifetimeObjects>
        <trial:TrialManager RunAsTrial="True" Expired="TrialManager_Expired" >
            <trial:TrialManager.ApplicationPolicy>
                <trial:UsageExpirationPolicy MaxUsage="5"/>
            </trial:TrialManager.ApplicationPolicy>
        </trial:TrialManager>
    </Application.ApplicationLifetimeObjects>

This will cause our WP7 application to instantiate the TrialManager every time the application loads.  It doesn’t matter if it is the first time the app launches of if we are pulling the app off the back stack, we will get a brand new TrialManager object.  Taking a look at the markup, there are a few things to note.  First, we can have the TrialManager to simulate that the application we are developing is running in trial mode by setting the RunAsTrial property to TrueTrialManager has its own IsTrial() method, just like the LicenseInformation class.  Normally, TrialManager.IsTrial() will create its own LicenseInformation object and return that object’s IsTrial() result.  When we set RunAsTrial to True, however, TrialManager will always return True for a call to IsTrial().  The code for TrialManager.IsTrial() is shown below:

if (this.RunAsTrial)
   return true;
else 
{
   if (_license == null)
      _license = new LicenseInformation();
   return _license.IsTrial();
}     

Second, TrialManager has an Expired event that is fired when the ExpirationPolicy object fires its own Expired event.  In the example above, we are wiring the Expired event to an event handler named TrialManager_Expired.  In the sample application, a MessageBox is shown when the application expires.  In your own application, you would probably do something like using the MarketPlaceLauncher to redirect the customer to your applications details page in order to buy a full version. 

The TrialManager’s behavior is controlled by the object assigned to the ApplicationProperty property.  This object must be derived from the ExpirationPolicy base class.  TrialManager comes with two implementations for you to use: UsageExpirationPolicy and TimeExpirationPolicy.  The UsageExpirationPolicy is the easiest to set up.  In our example, we are setting up a MaxUsage to 5.  What MaxUsage means is entirely up to you.  You control how to increment the UsageCount property.  You could do it each time the application starts or when a particular feature is used.  It is as easy as the following:

(TrialManager.Current.ApplicationPolicy as UsageExpirationPolicy).UsageCount++;

When UsageCount exceeds MaxCount, the UsageExpirationPolicy will fire its Expired events, which in turn causes TrialManager to fire its Expired event.

Setting Up and Using Trial Expiration

The other ExpirationPolicy derived class is the TimeExpirationPolicy. An example of configuring TrialManager to use the TimeExpirationPolicy is shown below:

<trial:TrialManager RunAsTrial="True" Expired="TrialManager_Expired" TimerInterval="00:05:00" >
   <trial:TrialManager.ApplicationPolicy>
       <trial:TimeExpirationPolicy TrialDuration="01:00:00" Mode="Lifetime" />
   </trial:TrialManager.ApplicationPolicy>
</trial:TrialManager>

In this case, we set up a TimeExpirationPolicy object in the XAML.  The most important property is the TrialDuration property.  Here, you set the TimeSpan that you want to make the application available before expiring.  The Mode property is optional.  By default, the Mode property is set to LifetimeLifetime durations mean that the cumulative ElapsedTime for the application is tracked each time the application is used.  If the user runs an application for five minutes the first time,  and fifteen minutes the second time, TrialManager will record this as twenty minutes of total usage and compare that value to the TrialDuration.  You can also set the Mode property to Session, which specifies that the ElapsedTime is reset to zero each time the application is launched.  When using the TimeExpirationPolicy, the TrialManager creates a DispatcherTimer and uses this to track the applications time usage.  By default, the DispatcherTimer.Interval property is set to one minute.  You can override Tick interval by setting the TimerInterval Property on the TrialManager.  In the example above, we are setting the Tick of the DispatcherTimer to five minutes.

Other Things About TriaManager

A couple of other notes about using TrialManager:

  • TrialManager has a DoNotPersist property.  By default, TrialManager will persist the state of the ExpirationPolicy to IsolatedStorage each time the application is exited (either via Deactivate or Closed).  This means the only way to get rid of persisted state information is to recycle the emulator.  Setting the DoNotPersist property to True will prevent the TrialManager from persisting state when the application is exited making debugging in certain situation easier.
  • The ExpirationPolicy base class has an Expired event.  This means you can hook up the Expired event at either the TrialManager or at the ExpirationPolicy level.  TrialManager actually hooks to the ExecutionPolicy’s Expired event and just fires its own Expired event when the ExpirationPolicy fires its event.  In the future, I see TrialManager having different ExpirationPolicy objects to control different features.  There will be an application level ExipirationPolicy, which will always cause the main TrialManager Expired event to fire.  Just an FYI…

 

Tags:

Headlines | Windows Phone

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen

About the author

Jeff Brand Jeff Brand

This is the personal web site of Jeff Brand, self-proclaimed .NET Sex Symbol and All-Around Good guy. Content from my presentations, blog, and links to other useful .NET information can all be found here.

E-mail me Send mail


Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

My Twitter Updates

XBOX
Live

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012

Sign in