Skip to content

Commit 4602729

Browse files
committed
Fix issue:(#168 )MultiSelectComboBox Visible Height
1 parent 3147cd2 commit 4602729

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/WPFDevelopers.Shared/Controls/MultiSelectComboBox/MultiSelectComboBox.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ protected override void OnSelectionChanged(SelectionChangedEventArgs e)
226226
{
227227
if (SelectedItemsExt is IList list)
228228
{
229-
list.Clear();
229+
if(list.Count > 0)
230+
list.Clear();
230231
foreach (var itm in SelectedItems.Cast<object>())
231232
list.Add(itm);
232233
}
@@ -248,7 +249,6 @@ protected override void OnItemsSourceChanged(IEnumerable oldValue, IEnumerable n
248249
ApplySearchLogic();
249250
}
250251

251-
252252
public override void OnApplyTemplate()
253253
{
254254
base.OnApplyTemplate();
@@ -308,6 +308,20 @@ public override void OnApplyTemplate()
308308
_panel = GetTemplateChild(PART_SimpleWrapPanel) as Panel;
309309
}
310310
}
311+
public MultiSelectComboBox()
312+
{
313+
IsVisibleChanged += OnMultiSelectComboBox_IsVisibleChanged;
314+
}
315+
316+
private void OnMultiSelectComboBox_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
317+
{
318+
if (Visibility == Visibility.Visible)
319+
{
320+
InvalidateMeasure();
321+
InvalidateArrange();
322+
UpdateLayout();
323+
}
324+
}
311325

312326
private void ApplySearchLogic()
313327
{
@@ -525,6 +539,7 @@ private void SearchText(string text)
525539

526540
private void SelectionChecked(ListBox listbox)
527541
{
542+
if (_checkBox == null) return;
528543
if (listbox.SelectedItems.Count > 0
529544
&&
530545
listbox.Items.Count == listbox.SelectedItems.Count)

0 commit comments

Comments
 (0)