Exemplo n.º 1
0
        /// <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));
        }
Exemplo n.º 2
0
 /// <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>();
     }
 }
Exemplo n.º 3
0
        /// <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>();
        }