protected override void OnApplyTemplate() { // Pass to base first base.OnApplyTemplate(); // Get the swap chain panel swapPanel = GetTemplateChild(SWAP_PANEL_NAME) as SwapChainPanel; // Ensure panel was found if (swapPanel == null) { throw new InvalidOperationException($"A {nameof(SwapChainPanel)} named {SWAP_PANEL_NAME} is required in the control template."); } // Attempt to get the preview element placeholderElement = GetTemplateChild(PLACEHOLDER_ELEMENT_NAME) as UIElement; // Panel found. If not in design mode, load Unity. if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { // Get the bridge bridge = UnityBridge.Instance; // Subscribe to bridge events bridge.RenderingStarted += Bridge_RenderingStarted; // Initialize Unity bridge.Initialize(this, swapPanel); } }
/// <summary> /// Initializes <see cref="UnityHelpers"/> /// </summary> static UnityHelpers() { bridge = UnityBridge.Instance; }