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(); }
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); }
private void OnWindowShown(IVisualHost window) { _inputContext = new InputContext(window, new BaseInputHandler(RenderContext)); }
private void OnWindowShown(IVisualHost visualHost) { _visualHost = visualHost; _windowProvider.WindowShown -= OnWindowShown; }
public void SetVisualHost(IVisualHost visualHost) { _window = visualHost; }