public static Remove ( System.Windows.Documents.Adorner adorner ) : void | ||
adorner | System.Windows.Documents.Adorner | |
return | void |
private static void OnIsShowingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var element = (UIElement)d; if (Equals(e.NewValue, true)) { var adorner = element.GetAdorner(); if (adorner == null) { adorner = TemplatedAdorner.Create(element, (ControlTemplate)element.GetValue(TemplateProperty)); element.SetAdorner(adorner); } AdornerService.Show(adorner); } else { var adorner = element.GetAdorner(); if (adorner != null) { AdornerService.Remove(adorner); } element.ClearValue(AdornerProperty); } }
private static void OnIsShowingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var element = (UIElement)d; if (Equals(e.NewValue, true)) { var adorner = element.GetAdorner(); if (adorner == null) { var adornedElement = element is Window ? element.FirstOrDefaultRecursiveVisualChild <AdornerDecorator>()?.Child : element; adorner = new ContentAdorner(adornedElement); element.SetAdorner(adorner); } SetIfNotNull(d, ContentProperty, adorner, ContentAdorner.ContentProperty); SetIfNotNull(d, ContentTemplateProperty, adorner, ContentAdorner.ContentTemplateProperty); SetIfNotNull(d, ContentTemplateSelectorProperty, adorner, ContentAdorner.ContentTemplateSelectorProperty); SetIfNotNull(d, ContentPresenterStyleProperty, adorner, ContentAdorner.ContentPresenterStyleProperty); AdornerService.Show(adorner); } else { var adorner = element.GetAdorner(); if (adorner != null) { AdornerService.Remove(adorner); } element.ClearValue(AdornerProperty); } }
private static void OnIsShowingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var element = (UIElement)d; if (Equals(e.NewValue, true)) { var adorner = element.GetAdorner(); if (adorner == null) { adorner = new ContentAdorner(element); element.SetAdorner(adorner); } SetIfNotNull(d, ContentProperty, adorner, ContentAdorner.ContentProperty); SetIfNotNull(d, ContentTemplateProperty, adorner, ContentAdorner.ContentTemplateProperty); SetIfNotNull(d, ContentTemplateSelectorProperty, adorner, ContentAdorner.ContentTemplateSelectorProperty); SetIfNotNull(d, ContentPresenterStyleProperty, adorner, ContentAdorner.ContentPresenterStyleProperty); AdornerService.Show(adorner); } else { var adorner = element.GetAdorner(); if (adorner != null) { AdornerService.Remove(adorner); } element.ClearValue(AdornerProperty); } }
private static void OnIsShowingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var adornedElement = (Control)d; if (Equals(e.NewValue, true)) { var adorner = adornedElement.GetAdorner(); if (adorner == null) { adorner = new WatermarkAdorner(adornedElement); adornedElement.SetAdorner(adorner); var textStyle = adornedElement.GetTextStyle(); if (textStyle != null) { adorner.SetCurrentValue(WatermarkAdorner.TextStyleProperty, textStyle); } AdornerService.Show(adorner); adornedElement.SetCurrentValue(AdornerProperty, adorner); } else { Debug.Assert(condition: false, message: "Already visible"); } } else { var adorner = adornedElement.GetAdorner(); if (adorner != null) { AdornerService.Remove(adorner); adornedElement.ClearValue(AdornerProperty); } } }
private static void OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (Equals(e.NewValue, true)) { if (d.GetValue(AdornerProperty) is null) { var adorner = new ContentAdorner(AdornedElement()) { Content = d.GetValue(ContentProperty), ContentTemplate = (DataTemplate)d.GetValue(ContentTemplateProperty), ContentTemplateSelector = (DataTemplateSelector)d.GetValue(ContentTemplateSelectorProperty), ContentPresenterStyle = (Style)d.GetValue(ContentPresenterStyleProperty), }; d.SetCurrentValue(AdornerProperty, adorner); AdornerService.Show(adorner); } else { Debug.Assert(condition: false, message: $"Element {d} already has an info adorner."); } } else if (d.GetValue(AdornerProperty) is ContentAdorner adorner) { AdornerService.Remove(adorner); d.ClearValue(AdornerProperty); } UIElement AdornedElement() { if (d is Window window && window.FirstRecursiveVisualChild <AdornerDecorator>() is { Child : { } adornerDecoratorChild }) { return(adornerDecoratorChild); } return((UIElement)d); }
private static void OnIsShowingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { //Debug.Print($"Visible changed to: {e.NewValue}"); var textBox = (TextBox)d; if (Equals(e.NewValue, true)) { var adorner = textBox.GetAdorner(); if (adorner == null) { adorner = new WatermarkAdorner(textBox); textBox.SetAdorner(adorner); var textStyle = textBox.GetTextStyle(); if (textStyle != null) { adorner.SetCurrentValue(WatermarkAdorner.TextStyleProperty, textStyle); } AdornerService.Show(adorner); textBox.SetValue(AdornerProperty, adorner); } else { Debug.Assert(false, "Already visible"); } } else { var adorner = textBox.GetAdorner(); if (adorner != null) { AdornerService.Remove(adorner); textBox.ClearValue(AdornerProperty); } } }