Thinking Out of the Box

From windows to tiles: Leveraging reflection to inspect and contrast WPF with WinRT XAML

Philip Schäfer

To begin with, our primal, simple aim was contrasting several concepts as applied in good old WPF with the way they have been implemented in WinRT . To actually enable a both exhaustive and reasonable comparison between both UI frameworks, we pragmatically decided to unleash some reflection functionality on the respectively affected assemblies. That being said, it turned out that scouring all eligible assemblies for usages of a certain type, let´s say ICommand, appears not to be as straight forward in a Windows Store app as it does in WPF. For instance, let´s assume we want to determine all occurrences of implementations of the ICommand interface within WPF; therefore, we require some functionality to examine all types being defined in WPF-related assemblies such as WindowsBase, PresentationCore and PresentationFramework. Taking a WPF project as granted, we may now exploit the .NET-Framework’s capability to access the current application domain and simply iterate over all assemblies therein:

Unfortunately, this approach proved to be desperately unsatisfactory in our Windows Store app as we could not access our application´s domain from within the WinRT API. Thus, we required a different strategy.

Examining our Windows store app project´s structure in a bit more detail, we figured out that the VS-generated references linked to the “Windows SDK” that comes shipped as “Windows.winmd” and to a set of DLLs called “.NET for Windows Store apps”.

Conveniently, the Windows.winmd is supplemented with an XML-formatted file (named “Windows.xml”) containing metadata of its types, properties and namespaces. Eventually, we decided to utilize this file by simply traversing its tree and successively reflecting any type contained.

Similarly, we subsequently implemented a function to search the remaining DLLs that are collectively referred to as “.NET for Windows Store apps”. Even though these assemblies are available as plain old DLLs, we could not simply reflect them by parsing their file path as the Assembly.LoadFrom(assemblyFile:String) method does not exist anymore. Instead, we need an assembly´s full name to load it. Fortunately, we could find a further XML-file (“FrameworkList.xml”) in one of the referenced directory´s subfolders containing a list of all comprised assemblies including their full names. Finally, we used this file to iterate over all assemblies to extract their full names and to reflect them subsequently.

Want to know more about our services, products or our UX process?
We are looking forward to hearing from you.

Luzie Seeliger

Project Coordination and Communication

+49 681 959 3110

Contact form

  • Saarbrücken

    Science Park Saar, Saarbrücken

    South West Location

    Headquarter Saarbrücken
    Centigrade GmbH
    Science Park 2
    66123 Saarbrücken
    On the map

    +49 681 959 3110

    +49 681 959 3119

  • Mülheim an der Ruhr

    Games Factory Mühlheim an der Ruhr

    North West Location

    Office Mülheim
    Centigrade GmbH
    Kreuzstraße 1-3
    45468 Mülheim an der Ruhr
    North Rhine-Westphalia
    On the map

    +49 208 883 672 89

    +49 681 959 3119

  • Haar · Munich

    Haar / München

    South Location

    Office Munich
    Centigrade GmbH
    Bahnhofstraße 18
    85540 Haar · Munich
    On the map

    +49 89 20 96 95 94

    +49 681 959 3119

  • Frankfurt am Main

    Frankfurt am Main

    Central Location

    Office Frankfurt
    Centigrade GmbH
    Kaiserstraße 61
    60329 Frankfurt am Main
    On the map

    +49 69 241 827 91

    +49 681 959 3119