/// <summary> /// Show the watermark on the specified control /// </summary> /// <param name="control">Control to show the watermark on</param> private static void ShowWatermark(Control control) { // Remove the old watermark. control.TryRemoveAdorners <WatermarkAdorner>(); // Add the new watermark. FrameworkElement content = GetContent(control); control.TryAddAdorner <WatermarkAdorner>(new WatermarkAdorner(control, content)); }
/// <summary> /// Updates the watermark. /// </summary> /// <param name="control">The control.</param> private static void UpdateWatermark(Control control) { if (ShouldShowWatermark(control)) { ShowWatermark(control); } else { control.TryRemoveAdorners <WatermarkAdorner>(); } }
/// <summary> /// Handle the GotFocus event on the control /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">A <see cref="RoutedEventArgs" /> that contains the event data.</param> private static void Control_GotKeyboardFocus(object sender, RoutedEventArgs e) { Control c = (Control)sender; c.TryRemoveAdorners <WatermarkAdorner>(); }