Managed controls (e.g. Popup coupled with Grid) in a Metro DirectX application


  • As I am developing a DirectX game (C++/Metro), I decided to implement the Settings charm.  I can normally access the Settings pane, but would also like to extend its capabilities by providing a more extensive set of customizations.

    I created a managed C# Metro DLL that compiles to a WinMD file, that I later add as a reference in my DirectX project. The code in the C# project is very simplistic (for testing purposes):

    using System;
    using Windows.UI;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Media;
    namespace PopupHandler
        public sealed class SettingsCharmHelper
            async public static void ShowAudioSettings()
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                () =>
                    Popup popup = new Popup();
                    popup.Height = 699;
                    popup.Width = 300;
                    Grid grid = new Grid();
                    grid.Width = 100;
                    grid.Height = 200;
                    grid.Background = new SolidColorBrush(Colors.Black);
                    grid.Children.Add(new TextBox() { Width = 50, Height = 50 });
                    popup.Child = grid;
                    popup.IsOpen = true;

    When I run the DirectX application and call the method shown above via PopupHandler::SettingsCharmHelper::ShowAudioSettings();, I get this:

    Is it safe to assume that I cannot use XAML controls like that in a Metro DirectX application (outside the Direct2D+XAML project scope) or there is something that I am missing?

    Thursday, July 19, 2012 10:13 PM


All replies