Skip to main content

Mixing UI controllers in a Windows Store App (Metro App) for Windows 8

More and more people (especially developer) are very excited about Windows 8 and the new features that come with him. As you already know we have free native languages that can be used to write Windows Store Applications (Metro Apps):
  • C++ using DirectX or XAML
  • C# using XAML
  • JavaScript using HTML5
Also we can use Visual Basic and XAML.
One interesting feature is the mixing components support. We can use components written in C# or C++ and use them in project written in JavaScript, C++ or C#. This is what WinMD and WinRT offer to us.
Because of this we can imagine a lot of scenarios developing a part of the application in C# and the UI part in JavaScript for example. Sounds great and this is possible and also recommended. We can develop great application in this way.
Also, WinRT API is not 100% available in any language. Even if JavaScript, C# and C++ are native languages and WinRT is native for all of them, there are things that can be done only from a specific language. For example if we want to write Windows events from our Windows Store App, this can be done only from C++. But this wills not a problem from us. We can very easily develop a component written in C++ that do this thing and use it from a JavaScript or C# project.
But what about mixing UI controllers and components. I can imagine a lot of scenarios where we could develop UI controller in C# and XAML and use it in JavaScript. Or to have a HTML and JavaScript component that can be used easily from XAML.
I will describe each scenario in part and see what is possible to accomplish.

UI controller written in HTML 5 and JavaScript for a C#/C++ and XAML application

Even if all the languages are native we will not be able to use the full power of a Page Control written in JavaScript from XAML. Even if we have a UI controller in XAML that can render HTML, this has some limitations. Because of this from this JavaScript files we will not able to call WinRT API and also to use the UI features that are supported in a HTML 5/CSS + JavaScript application for Windows Store.
Also, the output of a project written in JavaScript and HTML is not a WinMD component. It is a collection of files (HTML, JS and CSS). Because of this we cannot add a reference to a component written in JS - it doesn’t exist.

UI controller written in XAML and C#/C++ for a HTML 5/CSS and JavaScript application

Like in the previous case this is not possible in this moment. Even if we will have a WinMD component that contains our custom controller written in XAML and we will be able to add a reference to our HTML5/JS project to our WinMD component. The problem will be with the XAML UI libraries, that don’t exist in a HTML5/JS project. Even if the UI controllers written for HTML5 and XAML looks the same and have the same features, their implementation is not 100% the same. One need to be able to be rendered in a XAML and the other one will be displayed using Chakra and Trident. Because of this a HTML5/JS project will not contain the library that need is able to render the XAML controller.
Another problem is related to the tags. We don’t have a tag that can host and render an XAML component.

UI controller written in XAML and C++ for a XAML application written in C#

This is full supported and we will not have any kind of problems. Both projects type will generate a WinMD controller that can be reused without any kind of problems. Both of them use the same WinMD component to render the XAML.

UI controller written in XAML and C# for a C++ application written in C++ that uses DirectX support

Like the previous case this is full supported. An example that I like to use for this case is when we develop a game in C++ and use DirectX. For this case, the menu of the game can be written is XAML and C# because is more easily. Without any problem we will be able to overlap the XAML controller over our application.

As you can see we can have a lot of combination and a part of them all full supported. Before starting an application we should know exactly what UI components we would like to reuse and in what type of applications. The most important thing that we need to remember is: “We cannot use XAML controllers in a HTML5/JS project – in this moment”.

Comments

  1. Interesting, but.. what is a UI controller?

    About C++, I would say that there are at least two options to develop WinRT apps:
    - standard C++ directly using WRL or COM (for an experienced C++/ATL/MFC programmer this should not be too complicated)

    or the new option:
    - C++/CX + WinRT

    ReplyDelete

Post a Comment

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(...

How to audit an Azure Cosmos DB

In this post, we will talk about how we can audit an Azure Cosmos DB database. Before jumping into the problem let us define the business requirement: As an Administrator I want to be able to audit all changes that were done to specific collection inside my Azure Cosmos DB. The requirement is simple, but can be a little tricky to implement fully. First of all when you are using Azure Cosmos DB or any other storage solution there are 99% odds that you’ll have more than one system that writes data to it. This means that you have or not have control on the systems that are doing any create/update/delete operations. Solution 1: Diagnostic Logs Cosmos DB allows us activate diagnostics logs and stream the output a storage account for achieving to other systems like Event Hub or Log Analytics. This would allow us to have information related to who, when, what, response code and how the access operation to our Cosmos DB was done. Beside this there is a field that specifies what was th...

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills)

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills) The idea that moving to the cloud reduces the costs is a common misconception. The cloud infrastructure provides flexibility, scalability, and better CAPEX, but it does not guarantee lower costs without proper optimisation and management of the cloud services and infrastructure. Idle and unused resources, overprovisioning, oversize databases, and unnecessary data transfer can increase running costs. The regional pricing mode, multi-cloud complexity, and cost variety add extra complexity to the cost function. Cloud adoption without a cost governance strategy can result in unexpected expenses. Improper usage, combined with a pay-as-you-go model, can result in a nightmare for business stakeholders who cannot track and manage the monthly costs. Cloud-native services such as AI services, managed databases, and analytics platforms are powerful, provide out-of-the-shelve capabilities, and increase business agility and innovation. H...