locked
Is it possible to use a user control written in C# in a native C++ Windows Store application?

    Question

  • Is it possible to use a user control written in C# in a native C++ Windows Store application?

    I’ve seen this done going the other way (C# app using a control written in C++), but I’m beginning to suspect that a C++ application cannot use a C# control.

    I have built two simple test apps.

    The first app (the working one) was created as a C# “Windows Store Blank App(XAML)” application, where I added a C# “Class Library (Windows Store apps) to contain my test user control.  Inside the new class library, I added a C# “User Control” (and added a grid with some color just to see it.)

    I then used developer studio (after compiling) to add my control to the MainPage.xaml.

    This all worked great as I expected.

    The second application is built exactly like the first one, except the main app was created as a C++ “Windows Store Blank App(XAML)”.  All other steps were the same until I get to adding the control via developer studio… the control is not listed in the toolbox.

    No amount of hand-editing to add the control has proven to work.

    Just for the info, I am attempting to find a way to get the AdControl to work inside my C++ application, where it has come to my attention that the AdControl will not work with native C++.  My current attempt around this is to see if I could wrap the AdControl inside of a C# UserControl, but I can’t even get the UserControl to work… I’m really sensing a theme here.

    Thanks,

    Jim

    Friday, January 10, 2014 1:44 AM

Answers

  • You can implement and load your UserControl in a Windows Runtime Component written in C# in a C++ app. You cannot load a C# Class Library in a C++ app.

    --Rob

    Friday, January 10, 2014 2:13 AM
    Moderator