/// <summary> /// Creates the watermark label. /// </summary> /// <param name="controlBackground">The control.</param> private static void CreateWatermark(ControlBackground controlBackground) { if (controlBackground.Control != null && GetWatermarkUIElement(controlBackground.Control) == null) { controlBackground.CreateWatermarkLabelWithText(GetWatermarkText(controlBackground.Control)); } else { controlBackground.CreateWatermarkLabelWithUIElement(GetWatermarkUIElement(controlBackground.Control)); } }
/// <summary> /// Handles the Loaded event of the Control control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> private static void ControlLoaded(object sender, RoutedEventArgs e) { var control = sender as Control; if (control == null) { return; } // Save the original look of the control var newControlBackground = new ControlBackground { Control = control, OriginalBackground = control.Background }; CreateWatermark(newControlBackground); OriginalTextBoxBackgrounds.Add(newControlBackground); var stringProperty = GetWatermarkProperty(control); var propertyIsEmpty = string.IsNullOrWhiteSpace(stringProperty) ? CheckDefaultPropertiesEmptyOrNull(control) : PropertyIsEmpty(control, stringProperty); if (propertyIsEmpty) { ApplyWatermark(control, newControlBackground.WatermarkLabel); } }