Microsoft Surface – Turning WPF controls into Surface controls

When I first started learning Surface I quickly realized how to turn a WPF app into a surface app.  Basically, I did a search and replace for each control in the WPF app that has a matching control in Surface such as Button and TextBox.  By doing simple replacements I was able to get a surface app up and running quickly.  However, I recently learned a way to really extend this method.

All you need to do is edit the control template for the particular WPF control (that doesn’t have a surface twin) and in the template convert all instances of Button into s:SurfaceButton, all instances of Slider into s:SurfaceSlider, and the Thumb into s:SurfaceThumb, etc..  Just make sure you change both the controls themselves, as well as the control styles (for instance, if the first control in the template is a <Button> and it has a <Button.Style>, so change this to <s:SurfaceButton> and <s:SurfaceButton.Style>).

See my previous blog post for a way to get at the entire default control template for editing.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: