private void Show() { if (_adorner == null) { try { _adorner = new ControlAdorner(this) { Child = content }; } catch (Exception ex) { throw ex; } //System.Diagnostics.Debug.WriteLine("Show() new _adorner"); } AdornerLayer.GetAdornerLayer(this).Remove(_adorner); AdornerLayer.GetAdornerLayer(this).Add(_adorner); GetMouseCapture(content); }
private void Hide() { System.Diagnostics.Debug.WriteLine("Hide()"); RemoveMouseCapture(content); RemoveMouseCapture(_keeper); if (_adorner != null) { //System.Diagnostics.Debug.WriteLine("Hide() exists _adorner"); AdornerLayer.GetAdornerLayer(this).Remove(_adorner); _adorner.Child = null; _adorner = null; content.Visibility = System.Windows.Visibility.Collapsed; this.Content = content; } }
private void Show() { var holder = GetAdornerLayerHolderElement(); if (_adorner == null) { RemoveVisualChild(VisualTreeHelper.GetChild(this, 0) as FrameworkElement); var content = FormElement; if (double.IsNaN(content.Width)) { //var wBinding = new Binding("ActualWidth"); //wBinding.Source = holder; //BindingOperations.SetBinding(content, FrameworkElement.WidthProperty, wBinding); //content.Width = holder.ActualWidth; } if (double.IsNaN(content.Height)) { //var hBinding = new Binding("ActualHeight"); //hBinding.Source = holder; //BindingOperations.SetBinding(content, FrameworkElement.HeightProperty, hBinding); //content.Width = holder.ActualHeight; } try { _adorner = new ControlAdorner(this/*, holder*/) { Child = VisualTreeHelper.GetParent(content) as FrameworkElement }; } catch (Exception ex) { throw ex; } } var adrLayer = AdornerLayer.GetAdornerLayer(this); //LogicalTreeHelper adrLayer.Remove(_adorner); adrLayer.Add(_adorner); }