ZTextBoxBase.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. namespace CustomUI.MyControls.Primitives
  4. {
  5. public class ZTextBoxBase : TextBox
  6. {
  7. #region Watermark
  8. /// <summary>
  9. /// 获取或者设置水印
  10. /// </summary>
  11. public string Watermark
  12. {
  13. get { return (string)GetValue(WatermarkProperty); }
  14. set { SetValue(WatermarkProperty, value); }
  15. }
  16. public static readonly DependencyProperty WatermarkProperty =
  17. DependencyProperty.Register("Watermark", typeof(string), typeof(ZTextBoxBase));
  18. #endregion
  19. #region CornerRadius
  20. public CornerRadius CornerRadius
  21. {
  22. get { return (CornerRadius)GetValue(CornerRadiusProperty); }
  23. set { SetValue(CornerRadiusProperty, value); }
  24. }
  25. public static readonly DependencyProperty CornerRadiusProperty =
  26. DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ZTextBoxBase), new PropertyMetadata(CornerRadiusChanged));
  27. private static void CornerRadiusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  28. {
  29. ZTextBoxBase textbox = d as ZTextBoxBase;
  30. if(textbox != null && e.NewValue != null)
  31. {
  32. textbox.OnCornerRadiusChanged((CornerRadius)e.NewValue);
  33. }
  34. }
  35. #endregion
  36. public virtual void OnCornerRadiusChanged(CornerRadius newValue) { }
  37. }
  38. }