Files
ShrlAlgoToolkit/Melskin/Controls/PropertyField.xaml.cs
2026-02-17 22:17:13 +08:00

98 lines
2.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace Melskin.Controls;
/// <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);
}
/// <summary>
/// 用于注册属性名的依赖属性。
/// </summary>
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);
}
/// <summary>
/// 获取或设置属性的值。
/// </summary>
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);
}
/// <summary>
/// 获取或设置一个值,该值指示属性字段是否为只读。
/// </summary>
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);
}
/// <summary>
/// 获取或设置名称区域的宽度。
/// </summary>
public static readonly DependencyProperty NameAreaWidthProperty =
DependencyProperty.Register(nameof(NameAreaWidth), typeof(GridLength), typeof(PropertyField),
new PropertyMetadata(new GridLength(2, GridUnitType.Star)));
/// <summary>
/// 获取或设置值区域的宽度。此属性决定了在PropertyField控件中用于显示属性值部分的列宽。
/// </summary>
public GridLength ValueAreaWidth
{
get => (GridLength)GetValue(ValueAreaWidthProperty);
set => SetValue(ValueAreaWidthProperty, value);
}
/// <summary>
/// 获取或设置值区域的宽度。
/// </summary>
public static readonly DependencyProperty ValueAreaWidthProperty =
DependencyProperty.Register(nameof(ValueAreaWidth), typeof(GridLength), typeof(PropertyField),
new PropertyMetadata(new GridLength(3, GridUnitType.Star)));
}