namespace NeoUI.Assists; /// /// SelectorAssist 类提供了附加属性,用于增强选择器控件(如 ComboBox, ListBox 等)的功能。通过这些附加属性,可以设置选择器的方向和占位符文本。 /// public class SelectorAssist { /// /// 获取指定对象的Orientation属性值。 /// /// 要获取Orientation属性的对象。 /// 返回对象的Orientation属性值,可以是Horizontal或Vertical。 public static Orientation GetOrientation(DependencyObject obj) { return (Orientation)obj.GetValue(OrientationProperty); } /// /// 设置指定对象的Orientation属性。 /// /// 要设置Orientation属性的对象。 /// 要设置的Orientation值,可以是Horizontal或Vertical。 public static void SetOrientation(DependencyObject obj, Orientation value) { obj.SetValue(OrientationProperty, value); } /// /// 表示选择器控件的方向属性,可以用来设置或获取指定依赖对象的Orientation属性值。该属性支持两种方向:Horizontal(水平)和Vertical(垂直),默认值为Vertical。 /// public static readonly DependencyProperty OrientationProperty = DependencyProperty.RegisterAttached("Orientation", typeof(Orientation), typeof(SelectorAssist), new PropertyMetadata(Orientation.Vertical)); /// /// 获取指定对象的占位符文本。 /// /// 要获取占位符文本的对象。 /// 返回对象的占位符文本,如果未设置则返回默认值。 public static string GetPlaceholder(DependencyObject obj) { return (string)obj.GetValue(PlaceholderProperty); } /// /// 设置指定对象的占位符文本。 /// /// 要设置占位符文本的对象。 /// 要设置的占位符文本值。 public static void SetPlaceholder(DependencyObject obj, string value) { obj.SetValue(PlaceholderProperty, value); } /// /// 表示选择器控件的占位符文本属性,可以用来设置或获取指定依赖对象的占位符文本。默认值为"请选择...",用于在选择器没有选中项时显示提示信息。 /// public static readonly DependencyProperty PlaceholderProperty = DependencyProperty.RegisterAttached("Placeholder", typeof(string), typeof(SelectorAssist), new PropertyMetadata("请选择...")); }