Development of WinRT custom components

By Carol Rivera,2015-10-11 16:53
25 views 0
Development of WinRT custom components

    Development of WinRT custom components

    Recently began to develop components in the work, to meet the company's business and technical requirements, but also in route planning of component development, for the next generation of products technical reserves.

    On New Year's holiday at the component development in Windows 8, in addition to the traditional WPF, Windows Form, Silverlight, ASP.NET components, also added a WinRT component.

    WinRT = Windows Runtime, Windows 8 is newly introduced a new framework, aimed at the development of Windows platforms provide a language-independent, highly intelligent platform.

    Is not to replace, Win32, etc, but to provide unified support for programs written in different languages, especially the Metro style applications.

    The test code to download

    A, ready to work

    Install Windows 8 Developer Preview, VS 11 Developer Preview development tools, etc.

    When installing doing note to log in with the Windows Live ID, if it does not have to register a account, later won't be able to run Metro application.

    Install after doing to update the graphics drivers, AMD official provides Windows 8 drive, Nvidia use Windows 7 driver, ensure that the resolution of 1024 X 768 or higher.

    VS 11 suggest uninstall own Express version, install the fully functional Developer Preview version.

    In addition, SQL Server 2012 RC0 also has been released, suggest installation.

    Second,start developing

    2.1, to create a Windows Metro Style of the Class Library project:

    2.2, add a class:

2.3, writing a ButtonX, inherited from the Button:

WinRT component most in Windows. UI. Xaml. Controls namespace:

2.4, WinRT and WPF and Silverlight components are similar, I did just as

the gourd painting, in ButtonX add the following code:

2.5, a new Themes folder, add Generic. The xaml files, because there is no

resource dictionary this item type, so you need to add a Page, and then delete

the background code:

Use ResourceDictionary to load multiple components, respectively.

2.6, also add a ButtonX xaml, in which to write the following code:

    XMLNS: winrt = "CLR - namespace: Brooks. CustomerControl. Winrt" reference for adding prefix.

    2.7 at this time, if direct compilation, prompt the error:

    Google along while, didn't find a solution, simply put the missing files are copied to the corresponding position, did not think of.

    In this way, one of the most simple ButtonX component was finished, to create a new project to test the below.

    2.8, to create a Windows Metro Style of Application projects:

    Add the reference of the project:

    2.9, adding a Test. The xaml blank Page, at first I reference component like this:

    xmlns : winrt


    The runtime is always wrong, ButtonX type is unknown.

    Then I use the IDE to automatically add reference, the original is to use the using, and does not need to add the assembly.

    xmlns : winrt ="using:Brooks.CustomerControl.WinRT"

    So you can:

    2.10, write the following code in the click event, click a ButtonX is to increase the button width 5:

    Can see the effect after 2.11, run:

    At this point if using a local account login Windows 8 or display resolution is lower than 1024 X 768, is likely to appear similar to the error:

Look is permission problems, the Internet a lot of people are met.

Run successfully after the results are as follows:

In the navigation of Metro also can see the program:

Report this document

For any questions or suggestions please email