InfoElement.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System.Windows;
  2. using HandyControl.Data;
  3. namespace HandyControl.Controls;
  4. public class InfoElement : TitleElement
  5. {
  6. /// <summary>
  7. /// 占位符
  8. /// </summary>
  9. public static readonly DependencyProperty PlaceholderProperty = DependencyProperty.RegisterAttached(
  10. "Placeholder", typeof(string), typeof(InfoElement), new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.Inherits));
  11. public static void SetPlaceholder(DependencyObject element, string value) => element.SetValue(PlaceholderProperty, value);
  12. public static string GetPlaceholder(DependencyObject element) => (string) element.GetValue(PlaceholderProperty);
  13. /// <summary>
  14. /// 是否必填
  15. /// </summary>
  16. public static readonly DependencyProperty NecessaryProperty = DependencyProperty.RegisterAttached(
  17. "Necessary", typeof(bool), typeof(InfoElement), new FrameworkPropertyMetadata(ValueBoxes.FalseBox, FrameworkPropertyMetadataOptions.Inherits));
  18. public static void SetNecessary(DependencyObject element, bool value) => element.SetValue(NecessaryProperty, ValueBoxes.BooleanBox(value));
  19. public static bool GetNecessary(DependencyObject element) => (bool) element.GetValue(NecessaryProperty);
  20. /// <summary>
  21. /// 标记
  22. /// </summary>
  23. public static readonly DependencyProperty SymbolProperty = DependencyProperty.RegisterAttached(
  24. "Symbol", typeof(string), typeof(InfoElement), new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.Inherits));
  25. public static void SetSymbol(DependencyObject element, string value) => element.SetValue(SymbolProperty, value);
  26. public static string GetSymbol(DependencyObject element) => (string) element.GetValue(SymbolProperty);
  27. /// <summary>
  28. /// 内容高度
  29. /// </summary>
  30. public static readonly DependencyProperty ContentHeightProperty = DependencyProperty.RegisterAttached(
  31. "ContentHeight", typeof(double), typeof(InfoElement), new FrameworkPropertyMetadata(28.0, FrameworkPropertyMetadataOptions.Inherits));
  32. public static void SetContentHeight(DependencyObject element, double value) => element.SetValue(ContentHeightProperty, value);
  33. public static double GetContentHeight(DependencyObject element) => (double) element.GetValue(ContentHeightProperty);
  34. /// <summary>
  35. /// 最小内容高度
  36. /// </summary>
  37. public static readonly DependencyProperty MinContentHeightProperty = DependencyProperty.RegisterAttached(
  38. "MinContentHeight", typeof(double), typeof(InfoElement), new PropertyMetadata(28.0));
  39. public static void SetMinContentHeight(DependencyObject element, double value)
  40. => element.SetValue(MinContentHeightProperty, value);
  41. public static double GetMinContentHeight(DependencyObject element)
  42. => (double) element.GetValue(MinContentHeightProperty);
  43. /// <summary>
  44. /// 最大内容高度
  45. /// </summary>
  46. public static readonly DependencyProperty MaxContentHeightProperty = DependencyProperty.RegisterAttached(
  47. "MaxContentHeight", typeof(double), typeof(InfoElement), new PropertyMetadata(double.PositiveInfinity));
  48. public static void SetMaxContentHeight(DependencyObject element, double value)
  49. => element.SetValue(MaxContentHeightProperty, value);
  50. public static double GetMaxContentHeight(DependencyObject element)
  51. => (double) element.GetValue(MaxContentHeightProperty);
  52. /// <summary>
  53. /// 正则表达式
  54. /// </summary>
  55. public static readonly DependencyProperty RegexPatternProperty = DependencyProperty.RegisterAttached(
  56. "RegexPattern", typeof(string), typeof(InfoElement), new PropertyMetadata(default(string)));
  57. public static void SetRegexPattern(DependencyObject element, string value)
  58. => element.SetValue(RegexPatternProperty, value);
  59. public static string GetRegexPattern(DependencyObject element)
  60. => (string) element.GetValue(RegexPatternProperty);
  61. public static readonly DependencyProperty ShowClearButtonProperty = DependencyProperty.RegisterAttached(
  62. "ShowClearButton", typeof(bool), typeof(InfoElement), new PropertyMetadata(ValueBoxes.FalseBox));
  63. public static void SetShowClearButton(DependencyObject element, bool value)
  64. => element.SetValue(ShowClearButtonProperty, ValueBoxes.BooleanBox(value));
  65. public static bool GetShowClearButton(DependencyObject element)
  66. => (bool) element.GetValue(ShowClearButtonProperty);
  67. public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.RegisterAttached(
  68. "IsReadOnly", typeof(bool), typeof(InfoElement), new PropertyMetadata(ValueBoxes.FalseBox));
  69. public static void SetIsReadOnly(DependencyObject element, bool value) => element.SetValue(IsReadOnlyProperty, ValueBoxes.BooleanBox(value));
  70. public static bool GetIsReadOnly(DependencyObject element) => (bool) element.GetValue(IsReadOnlyProperty);
  71. }