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):
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.
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.
Another problem is related to the tags. We don’t have a tag that can host and render an XAML component.
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”.
- C++ using DirectX or XAML
- C# using XAML
- JavaScript using HTML5
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”.
Interesting, but.. what is a UI controller?
ReplyDeleteAbout 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