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(

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine: threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration: TeamCity .NET 4.51 EF 6.0.2 VS2013 It see

Navigating Cloud Strategy after Azure Central US Region Outage

 Looking back, July 19, 2024, was challenging for customers using Microsoft Azure or Windows machines. Two major outages affected customers using CrowdStrike Falcon or Microsoft Azure computation resources in the Central US. These two outages affected many people and put many businesses on pause for a few hours or even days. The overlap of these two issues was a nightmare for travellers. In addition to blue screens in the airport terminals, they could not get additional information from the airport website, airline personnel, or the support line because they were affected by the outage in the Central US region or the CrowdStrike outage.   But what happened in reality? A faulty CrowdStrike update affected Windows computers globally, from airports and healthcare to small businesses, affecting over 8.5m computers. Even if the Falson Sensor software defect was identified and a fix deployed shortly after, the recovery took longer. In parallel with CrowdStrike, Microsoft provided a too