优化更新代码,添加界面功能并整合
This commit is contained in:
63
WPFluent/Controls/CheckComboBox/CheckComboBoxItem.cs
Normal file
63
WPFluent/Controls/CheckComboBox/CheckComboBoxItem.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace WPFluent.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// 选择行
|
||||
/// </summary>
|
||||
public class CheckComboBoxItem : ListBoxItem
|
||||
{
|
||||
#region Constructors
|
||||
static CheckComboBoxItem()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(
|
||||
typeof(CheckComboBoxItem),
|
||||
new FrameworkPropertyMetadata(typeof(CheckComboBoxItem)));
|
||||
}
|
||||
#endregion
|
||||
|
||||
public CheckComboBoxItem()
|
||||
{
|
||||
}
|
||||
|
||||
#region PrivateProperty
|
||||
/// <summary>
|
||||
/// 包含该CheckComboBoxItem的CheckComboBox控件
|
||||
/// </summary>
|
||||
private CheckComboBox ParentCheckComboBox
|
||||
{
|
||||
get { return ItemsControl.ItemsControlFromItemContainer(this) as CheckComboBox; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Override
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DependencyProperty
|
||||
public new static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
|
||||
nameof(IsSelected),
|
||||
typeof(bool),
|
||||
typeof(CheckComboBoxItem),
|
||||
new PropertyMetadata(false, OnSelectedChanged));
|
||||
|
||||
/// <summary>
|
||||
/// 选中
|
||||
/// </summary>
|
||||
public new bool IsSelected
|
||||
{
|
||||
get { return (bool)GetValue(IsSelectedProperty); }
|
||||
set { SetValue(IsSelectedProperty, value); }
|
||||
}
|
||||
|
||||
private static void OnSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var ComboBoxItem = d as CheckComboBoxItem;
|
||||
ComboBoxItem?.ParentCheckComboBox?.NotifyCheckComboBoxItemClicked(ComboBoxItem);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user