namespace VariaStudio.Controls; /// /// 带有名称的属性输入 /// public class PropertyField : Control { static PropertyField() { DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyField), new FrameworkPropertyMetadata(typeof(PropertyField))); } /// /// 属性名 /// public string PropertyName { get => (string)GetValue(PropertyNameProperty); set => SetValue(PropertyNameProperty, value); } /// /// 用于注册属性名的依赖属性。 /// public static readonly DependencyProperty PropertyNameProperty = DependencyProperty.Register(nameof(PropertyName), typeof(string), typeof(PropertyField)); /// /// 属性值 /// public string PropertyValue { get => (string)GetValue(PropertyValueProperty); set => SetValue(PropertyValueProperty, value); } /// /// 获取或设置属性的值。 /// public static readonly DependencyProperty PropertyValueProperty = DependencyProperty.Register(nameof(PropertyValue), typeof(string), typeof(PropertyField)); /// /// 是否只读 /// public bool ReadOnly { get => (bool)GetValue(ReadOnlyProperty); set => SetValue(ReadOnlyProperty, value); } /// /// 获取或设置一个值,该值指示属性字段是否为只读。 /// public static readonly DependencyProperty ReadOnlyProperty = DependencyProperty.Register(nameof(ReadOnly), typeof(bool), typeof(PropertyField), new PropertyMetadata(false)); /// /// 名称区域宽度 /// public GridLength NameAreaWidth { get => (GridLength)GetValue(NameAreaWidthProperty); set => SetValue(NameAreaWidthProperty, value); } /// /// 获取或设置名称区域的宽度。 /// public static readonly DependencyProperty NameAreaWidthProperty = DependencyProperty.Register(nameof(NameAreaWidth), typeof(GridLength), typeof(PropertyField), new PropertyMetadata(new GridLength(2, GridUnitType.Star))); /// /// 获取或设置值区域的宽度。此属性决定了在PropertyField控件中,用于显示属性值部分的列宽。 /// public GridLength ValueAreaWidth { get => (GridLength)GetValue(ValueAreaWidthProperty); set => SetValue(ValueAreaWidthProperty, value); } /// /// 获取或设置值区域的宽度。 /// public static readonly DependencyProperty ValueAreaWidthProperty = DependencyProperty.Register(nameof(ValueAreaWidth), typeof(GridLength), typeof(PropertyField), new PropertyMetadata(new GridLength(3, GridUnitType.Star))); }