Divider.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Markup;
  4. using System.Windows.Media;
  5. using HandyControl.Data;
  6. namespace HandyControl.Controls;
  7. [ContentProperty(nameof(Content))]
  8. public class Divider : Control
  9. {
  10. public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(
  11. nameof(Content), typeof(object), typeof(Divider), new PropertyMetadata(default(object)));
  12. public object Content
  13. {
  14. get => GetValue(ContentProperty);
  15. set => SetValue(ContentProperty, value);
  16. }
  17. public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
  18. nameof(Orientation), typeof(Orientation), typeof(Divider), new PropertyMetadata(default(Orientation)));
  19. public Orientation Orientation
  20. {
  21. get => (Orientation) GetValue(OrientationProperty);
  22. set => SetValue(OrientationProperty, value);
  23. }
  24. public static readonly DependencyProperty ContentTemplateProperty = DependencyProperty.Register(
  25. nameof(ContentTemplate), typeof(DataTemplate), typeof(Divider), new PropertyMetadata(default(DataTemplate)));
  26. public DataTemplate ContentTemplate
  27. {
  28. get => (DataTemplate) GetValue(ContentTemplateProperty);
  29. set => SetValue(ContentTemplateProperty, value);
  30. }
  31. public static readonly DependencyProperty ContentStringFormatProperty = DependencyProperty.Register(
  32. nameof(ContentStringFormat), typeof(string), typeof(Divider), new PropertyMetadata(default(string)));
  33. public string ContentStringFormat
  34. {
  35. get => (string) GetValue(ContentStringFormatProperty);
  36. set => SetValue(ContentStringFormatProperty, value);
  37. }
  38. public static readonly DependencyProperty ContentTemplateSelectorProperty = DependencyProperty.Register(
  39. nameof(ContentTemplateSelector), typeof(DataTemplateSelector), typeof(Divider), new PropertyMetadata(default(DataTemplateSelector)));
  40. public DataTemplateSelector ContentTemplateSelector
  41. {
  42. get => (DataTemplateSelector) GetValue(ContentTemplateSelectorProperty);
  43. set => SetValue(ContentTemplateSelectorProperty, value);
  44. }
  45. public static readonly DependencyProperty LineStrokeProperty = DependencyProperty.Register(
  46. nameof(LineStroke), typeof(Brush), typeof(Divider), new PropertyMetadata(default(Brush)));
  47. public Brush LineStroke
  48. {
  49. get => (Brush) GetValue(LineStrokeProperty);
  50. set => SetValue(LineStrokeProperty, value);
  51. }
  52. public static readonly DependencyProperty LineStrokeThicknessProperty = DependencyProperty.Register(
  53. nameof(LineStrokeThickness), typeof(double), typeof(Divider), new PropertyMetadata(ValueBoxes.Double1Box));
  54. public double LineStrokeThickness
  55. {
  56. get => (double) GetValue(LineStrokeThicknessProperty);
  57. set => SetValue(LineStrokeThicknessProperty, value);
  58. }
  59. public static readonly DependencyProperty LineStrokeDashArrayProperty = DependencyProperty.Register(
  60. nameof(LineStrokeDashArray), typeof(DoubleCollection), typeof(Divider), new PropertyMetadata(new DoubleCollection()));
  61. public DoubleCollection LineStrokeDashArray
  62. {
  63. get => (DoubleCollection) GetValue(LineStrokeDashArrayProperty);
  64. set => SetValue(LineStrokeDashArrayProperty, value);
  65. }
  66. }