LabelEditor.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. namespace FWindSoft.Wpf.Controls
  11. {
  12. public class LabelEditor: HeaderedContentControl
  13. {
  14. public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation",
  15. typeof(Orientation),
  16. typeof(LabelEditor), new PropertyMetadata(Orientation.Horizontal));
  17. public static readonly DependencyProperty LabelWidthProperty = DependencyProperty.Register("LabelWidth",
  18. typeof(double),
  19. typeof(LabelEditor), new PropertyMetadata(0d));
  20. public static readonly DependencyProperty LabelHeightProperty = DependencyProperty.Register(" LabelHeight",
  21. typeof(double),
  22. typeof(LabelEditor), new PropertyMetadata(0d));
  23. public static readonly DependencyProperty LabelHorizontalAlignmentProperty = DependencyProperty.Register(" LabelHorizontalAlignment",
  24. typeof(HorizontalAlignment),
  25. typeof(LabelEditor), new PropertyMetadata(HorizontalAlignment.Right));
  26. static LabelEditor()
  27. {
  28. DefaultStyleKeyProperty.OverrideMetadata(typeof(LabelEditor),
  29. new FrameworkPropertyMetadata(typeof(LabelEditor)));
  30. }
  31. public LabelEditor()
  32. {
  33. this.HorizontalContentAlignment = HorizontalAlignment.Stretch;
  34. this.VerticalContentAlignment = VerticalAlignment.Stretch;
  35. }
  36. #region 依赖属性
  37. /// <summary>
  38. /// 关联显示属性集合
  39. /// </summary>
  40. public Orientation Orientation
  41. {
  42. get { return (Orientation)GetValue(OrientationProperty); }
  43. set { SetValue(OrientationProperty, value); }
  44. }
  45. /// <summary>
  46. /// 标签宽度
  47. /// </summary>
  48. public Double LabelWidth
  49. {
  50. get { return (double)GetValue(LabelWidthProperty); }
  51. set { SetValue(LabelWidthProperty, value); }
  52. }
  53. /// <summary>
  54. /// 变迁高度
  55. /// </summary>
  56. public Double LabelHeight
  57. {
  58. get { return (double)GetValue(LabelHeightProperty); }
  59. set { SetValue(LabelHeightProperty, value); }
  60. }
  61. public HorizontalAlignment LabelHorizontalAlignment
  62. {
  63. get { return (HorizontalAlignment)GetValue(LabelHorizontalAlignmentProperty); }
  64. set { SetValue(LabelHorizontalAlignmentProperty, value); }
  65. }
  66. #endregion
  67. }
  68. }