ZTextBox.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. namespace CustomUI
  4. {
  5. public class ZTextBox : TextBox
  6. {
  7. #region Private属性
  8. #endregion
  9. #region 依赖属性定义
  10. public static readonly DependencyProperty CornerRadiusProperty;
  11. public static readonly DependencyProperty WatermarkProperty;
  12. public static readonly DependencyProperty MultiRowProperty;
  13. #endregion
  14. #region Constructors
  15. static ZTextBox()
  16. {
  17. DefaultStyleKeyProperty.OverrideMetadata(typeof(ZTextBox), new FrameworkPropertyMetadata(typeof(ZTextBox)));
  18. CornerRadiusProperty = DependencyProperty.Register("CornerRadius",
  19. typeof(System.Windows.CornerRadius), typeof(ZTextBox));
  20. WatermarkProperty = DependencyProperty.Register("Watermark",
  21. typeof(string), typeof(ZTextBox));
  22. MultiRowProperty = DependencyProperty.Register("MultiRow",
  23. typeof(bool), typeof(ZTextBox));
  24. }
  25. #endregion
  26. #region 依赖属性set get
  27. /// <summary>
  28. /// 边框圆角
  29. /// </summary>
  30. public System.Windows.CornerRadius CornerRadius
  31. {
  32. get { return (System.Windows.CornerRadius)GetValue(CornerRadiusProperty); }
  33. set { SetValue(CornerRadiusProperty, value); }
  34. }
  35. /// <summary>
  36. /// 文本输入框的水印
  37. /// </summary>
  38. public string Watermark
  39. {
  40. get { return (string)GetValue(WatermarkProperty); }
  41. set { SetValue(WatermarkProperty, value); }
  42. }
  43. /// <summary>
  44. /// 多行
  45. /// </summary>
  46. public bool MultiRow
  47. {
  48. get { return (bool)GetValue(WatermarkProperty); }
  49. set { SetValue(WatermarkProperty, value); }
  50. }
  51. #endregion
  52. #region Override方法
  53. #endregion
  54. #region Private方法
  55. #endregion
  56. }
  57. }