Dissecting WinRT UserControl

UserControl seems to be one of the most commonly used controls in XAML languages. It most often is at the root of your XAML file structure and usually encapsulates reusable pieces of XAML. Let’s take a look at the class hierarchy and see if it is different than in Silverlight:







An Object in WinRT (WinRT being my shorthand for Immersive/Metro Windows 8 apps) is just a .NET System.Object.

DependencyObject “represents an object that participates in the dependency property system. DependencyObject is the immediate base class of many important UI-related classes, such as UIElement, Geometry, FrameworkTemplate, Style, and ResourceDictionary.”. It is then the base class for all controls and is required base class for use with bindings, (property value-) animations etc.
Comparing to Silverlight it is missing the CheckAccess property which you can use in Silverlight to see if you are running on a dispatcher thread, but it does still have the Dispatcher property which then gives you CoreDispatcher.HasThreadAccess to possibly gain the same information. Otherwise it has identically named members in both WinRT and Silverlight – methods for clearing, getting and setting dependency property values that depend on default values, set values, bindings, animations and possibly property inheritance.

UIElement is a base class for most of the objects that have visual appearance and can process basic input in a user interface.”. It provides access to events for handling touch, drag&drop, focus, keyboard input, pointer/stylus input (not directly supported in Silverlight), methods for handling layout and a Transitions property that is new to WinRT.

Looking at the stylus events – I started playing with the CapturePointer method (it captures stylus input to only be handled by the specific UIElement) which reminded me of a non-default way of testing WinRT apps – by using a Simulator. You go to project properties/Debug and switch Target Device to Simulator, then simply hit F5.


It looks a bit like a Surface or Windows Phone simulator, runs as a remote desktop connection to another session on your own machine and helps when you want to monitor VS Output window while running a full-screen immersive app…


Tagged , ,

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: