命令更新
This commit is contained in:
@@ -355,8 +355,7 @@ public class MultiComboBox : Control
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
if (listBox != null)
|
||||
listBox.SelectionChanged -= ListBox_SelectionChanged;
|
||||
listBox?.SelectionChanged -= ListBox_SelectionChanged;
|
||||
|
||||
listBox = GetTemplateChild("PART_ListBox") as ListBox;
|
||||
filterTextBox = GetTemplateChild("PART_FilterTextBox") as TextBox;
|
||||
@@ -564,8 +563,7 @@ public class MultiComboBox : Control
|
||||
private static void OnSelectionModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var c = (MultiComboBox)d;
|
||||
if (c.listBox != null)
|
||||
c.listBox.SelectionMode = c.SelectionMode;
|
||||
c.listBox?.SelectionMode = c.SelectionMode;
|
||||
|
||||
c.isUpdatingSelection = true;
|
||||
try
|
||||
@@ -620,7 +618,7 @@ public class MultiComboBox : Control
|
||||
// 1. 移除 ListBox 中有但源中没有的 (倒序遍历以安全删除)
|
||||
for (int i = controlList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (!sourceSet.Contains(controlList[i]))
|
||||
if (!sourceSet.Contains(controlList[i]!))
|
||||
{
|
||||
controlList.RemoveAt(i);
|
||||
}
|
||||
@@ -763,13 +761,13 @@ public class MultiComboBox : Control
|
||||
}
|
||||
|
||||
// 处理第一个元素
|
||||
if (IsMatch(firstItem, filter!, propDesc)) filtered.Add(firstItem);
|
||||
if (IsMatch(firstItem, filter!, propDesc)) filtered.Add(firstItem!);
|
||||
}
|
||||
|
||||
// 处理剩余元素
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
if (IsMatch(enumerator.Current, filter, propDesc))
|
||||
if (IsMatch(enumerator.Current, filter!, propDesc))
|
||||
filtered.Add(enumerator.Current);
|
||||
}
|
||||
|
||||
@@ -791,6 +789,6 @@ public class MultiComboBox : Control
|
||||
value = item.ToString();
|
||||
}
|
||||
|
||||
return value != null && value.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
return value != null && value.Contains(filter);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user