Update CheckComboBox.cs
This commit is contained in:
1 parent
6dd74fb44a
commit
c6a6469cd2
1 file changed
+25
-21
@@ -2,6 +2,7 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
using HandyControl.Interactivity;
|
using HandyControl.Interactivity;
|
||||||
@@ -103,14 +104,6 @@ namespace HandyControl.Controls
|
|||||||
CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) => SelectedItems.Clear()));
|
CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) => SelectedItems.Clear()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Tags_OnClosed(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.OriginalSource is Tag tag && tag.Tag is CheckComboBoxItem checkComboBoxItem)
|
|
||||||
{
|
|
||||||
checkComboBoxItem.SetCurrentValue(IsSelectedProperty, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnApplyTemplate()
|
public override void OnApplyTemplate()
|
||||||
{
|
{
|
||||||
if (_selectAllItem != null)
|
if (_selectAllItem != null)
|
||||||
@@ -161,6 +154,28 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
public Func<string, OperationResult<bool>> VerifyFunc { get; set; }
|
public Func<string, OperationResult<bool>> VerifyFunc { get; set; }
|
||||||
|
|
||||||
|
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
UpdateTags();
|
||||||
|
VerifyData();
|
||||||
|
|
||||||
|
base.OnSelectionChanged(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool IsItemItsOwnContainerOverride(object item) => item is CheckComboBoxItem;
|
||||||
|
|
||||||
|
protected override DependencyObject GetContainerForItemOverride() => new CheckComboBoxItem();
|
||||||
|
|
||||||
|
protected override void OnDisplayMemberPathChanged(string oldDisplayMemberPath, string newDisplayMemberPath) => UpdateTags();
|
||||||
|
|
||||||
|
private void Tags_OnClosed(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.OriginalSource is Tag tag && tag.Tag is CheckComboBoxItem checkComboBoxItem)
|
||||||
|
{
|
||||||
|
checkComboBoxItem.SetCurrentValue(IsSelectedProperty, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SwitchAllItems(bool selected)
|
private void SwitchAllItems(bool selected)
|
||||||
{
|
{
|
||||||
if (_isInternalAction) return;
|
if (_isInternalAction) return;
|
||||||
@@ -182,18 +197,6 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
private void SelectAllItem_Unselected(object sender, RoutedEventArgs e) => SwitchAllItems(false);
|
private void SelectAllItem_Unselected(object sender, RoutedEventArgs e) => SwitchAllItems(false);
|
||||||
|
|
||||||
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
UpdateTags();
|
|
||||||
VerifyData();
|
|
||||||
|
|
||||||
base.OnSelectionChanged(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool IsItemItsOwnContainerOverride(object item) => item is CheckComboBoxItem;
|
|
||||||
|
|
||||||
protected override DependencyObject GetContainerForItemOverride() => new CheckComboBoxItem();
|
|
||||||
|
|
||||||
private void UpdateTags()
|
private void UpdateTags()
|
||||||
{
|
{
|
||||||
if (_panel == null || _isInternalAction) return;
|
if (_panel == null || _isInternalAction) return;
|
||||||
@@ -214,9 +217,10 @@ namespace HandyControl.Controls
|
|||||||
var tag = new Tag
|
var tag = new Tag
|
||||||
{
|
{
|
||||||
Style = TagStyle,
|
Style = TagStyle,
|
||||||
Content = checkComboBoxItem.Content,
|
|
||||||
Tag = checkComboBoxItem
|
Tag = checkComboBoxItem
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tag.SetBinding(ContentControl.ContentProperty, new Binding(DisplayMemberPath) { Source = item });
|
||||||
_panel.Children.Add(tag);
|
_panel.Children.Add(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user