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