private void WebView_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
        {
            #if DEBUG
            Debug.WriteLine("Navigation Starting");
            #endif
            _parentAccessor = new ParentAccessor(this);
            _parentAccessor.RegisterAction("Loaded", async() =>
            {
                if (this.Decorations != null && this.Decorations.Count > 0)
                {
                    // Need to retrigger highlights after load if they were set before load.
                    await this.DeltaDecorationsHelperAsync(this.Decorations.ToArray());
                }

                // Now we're done loading
                Loading?.Invoke(this, new RoutedEventArgs());
            });

            _themeListener = new ThemeListener();
            _themeListener.ThemeChanged += _themeListener_ThemeChanged;

            this._view.AddWebAllowedObject("Debug", new DebugLogger());
            this._view.AddWebAllowedObject("Parent", _parentAccessor);
            this._view.AddWebAllowedObject("Theme", _themeListener);
            this._view.AddWebAllowedObject("Keyboard", new KeyboardListener(this));
        }
        private void WebView_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
        {
            #if DEBUG
            Debug.WriteLine("Navigation Starting");
            #endif
            _parentAccessor = new ParentAccessor(this, _queue);
            _parentAccessor.AddAssemblyForTypeLookup(typeof(Range).GetTypeInfo().Assembly);
            _parentAccessor.RegisterAction("Loaded", CodeEditorLoaded);

            _themeListener = new ThemeListener(_queue);
            _themeListener.ThemeChanged += ThemeListener_ThemeChanged;
            _themeToken = RegisterPropertyChangedCallback(RequestedThemeProperty, RequestedTheme_PropertyChanged);

            _keyboardListener = new KeyboardListener(this, _queue);

            _view.AddWebAllowedObject("Debug", new DebugLogger());
            _view.AddWebAllowedObject("Accessor", _parentAccessor);
            _view.AddWebAllowedObject("Theme", _themeListener); // TODO: Is this used?
            _view.AddWebAllowedObject("Keyboard", _keyboardListener);
        }
        private void CodeEditor_Loaded(object sender, RoutedEventArgs e)
        {
            // Do this the 2nd time around.
            if (_model == null && _view != null)
            {
                _model = new ModelHelper(this);

                _parentAccessor = new ParentAccessor(this);
                _parentAccessor.AddAssemblyForTypeLookup(typeof(Range).GetTypeInfo().Assembly);
                _parentAccessor.RegisterAction("Loaded", CodeEditorLoaded);

                _themeListener = new ThemeListener();
                _themeListener.ThemeChanged += _themeListener_ThemeChanged;
                _themeToken = RegisterPropertyChangedCallback(RequestedThemeProperty, RequestedTheme_PropertyChanged);

                _keyboardListener = new KeyboardListener(this);

                _view.AddWebAllowedObject("Parent", _parentAccessor);
                _view.AddWebAllowedObject("Theme", _themeListener);
                _view.AddWebAllowedObject("Keyboard", _keyboardListener);

                Options.PropertyChanged += Options_PropertyChanged;

                Decorations.VectorChanged += Decorations_VectorChanged;
                Markers.VectorChanged     += Markers_VectorChanged;

                _view.NewWindowRequested += WebView_NewWindowRequested;

                _initialized = true;

                Loading?.Invoke(this, new RoutedEventArgs());

                Unloaded += CodeEditor_Unloaded;

                Loaded?.Invoke(this, new RoutedEventArgs());
            }
        }