protected override void OnAttached()
        {
            _visualHost = FindVisualHost();
            if (_visualHost == null)
            {
                throw new InvalidOperationException("Visual host wasn't found in the data context hierarchy.");
            }

            _visualHost.Visual = AssociatedObject;

            base.OnAttached();
        }
示例#2
0
        private void OnWindowShown(IVisualHost window)
        {
            _windowProvider.WindowShown -= OnWindowShown;

            _window = window;
            _imageProvider.SetVisualHost(window);

            if (window is Control ctrl && ctrl.Controls.Count == 1)
            {
                _windowControl = ctrl.Controls[0];
                Container.ResolveTo(_windowControl);
            }
        private IVisualHost FindVisualHost()
        {
            DependencyObject targetObject = AssociatedObject;
            IVisualHost      visualHost   = AssociatedObject.DataContext as IVisualHost;

            while (targetObject != null)
            {
                if (visualHost != null)
                {
                    return(visualHost);
                }

                targetObject = VisualTreeHelper.GetParent(targetObject);
            }

            return(null);
        }
示例#4
0
 private void OnWindowShown(IVisualHost window)
 {
     _inputContext = new InputContext(window, new BaseInputHandler(RenderContext));
 }
示例#5
0
 private void OnWindowShown(IVisualHost visualHost)
 {
     _visualHost = visualHost;
     _windowProvider.WindowShown -= OnWindowShown;
 }
示例#6
0
 public void SetVisualHost(IVisualHost visualHost)
 {
     _window = visualHost;
 }