Using WP7 Controls in Silverlight Desktop

toggleIn building my WP7 apps I have taken the approach of dual coding wherever possible, that is to say that each solution has both a standard Silverlight project and a Windows Phone 7 project, with shared code (using shortcuts within the project) wherever possible.  My objective is to have the Silverlight Desktop version mimic the UI and behavior of the WP7 project.

Windows Phone 7 has a few new controls but a little digging (and I mean just a little) reveals that they are in fact standard controls with a style applied within the APP.XAML of the WP7 project.  SO it is simple a case of cutting and pasting the styles from the WP7 to the Desktop project!

For an example of the new toggle switch applied to a silverlight desktop project click on the options button in the top left corner of the following link:

http://apps.webservicesuk.com/shove

So the code for the checkbox within the options panel simply has the following style applied to it:

Style="{StaticResource PhoneToggleSwitch}"

 

This is also  useful when doing multi-touch desktop applications as the styles for all the WP7 controls provide a better staring point than the default desktop equivalents.

Advertisements

~ by Ian on July 5, 2010.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: