64 lines
1.8 KiB
C#
64 lines
1.8 KiB
C#
|
|
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
|
|||
|
|
}
|
|||
|
|
}
|