Skip to content

Commit

Permalink
Fix issue (#124
Browse files Browse the repository at this point in the history
Fix issue (#124
  • Loading branch information
yanjinhuagood committed Dec 1, 2024
1 parent d22e92d commit 29e96ba
Showing 1 changed file with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class MultiSelectionSearchComboBox : Control

public static readonly DependencyProperty SelectedItemsProperty =
DependencyProperty.Register("SelectedItems", typeof(IList), typeof(MultiSelectionSearchComboBox),
new FrameworkPropertyMetadata(null,
new FrameworkPropertyMetadata(new ArrayList(),
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal,
OnSelectedItemsChanged));

Expand Down Expand Up @@ -109,37 +109,37 @@ static MultiSelectionSearchComboBox()

public string Delimiter
{
get => (string) GetValue(DelimiterProperty);
get => (string)GetValue(DelimiterProperty);
set => SetValue(DelimiterProperty, value);
}

public string SelectedValuePath
{
get => (string) GetValue(SelectedValuePathProperty);
get => (string)GetValue(SelectedValuePathProperty);
set => SetValue(SelectedValuePathProperty, value);
}

public string DisplayMemberPath
{
get => (string) GetValue(DisplayMemberPathProperty);
get => (string)GetValue(DisplayMemberPathProperty);
set => SetValue(DisplayMemberPathProperty, value);
}

public string Text
{
get => (string) GetValue(TextProperty);
get => (string)GetValue(TextProperty);
set => SetValue(TextProperty, value);
}

public IEnumerable ItemsSource
{
get => (IEnumerable) GetValue(ItemsSourceProperty);
get => (IEnumerable)GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}

public IEnumerable ItemsSourceSearch
{
get => (IEnumerable) GetValue(ItemsSourceSearchProperty);
get => (IEnumerable)GetValue(ItemsSourceSearchProperty);
set => SetValue(ItemsSourceSearchProperty, value);
}

Expand All @@ -151,31 +151,31 @@ public object SelectAllContent

public bool IsSelectAllActive
{
get => (bool) GetValue(IsSelectAllActiveProperty);
get => (bool)GetValue(IsSelectAllActiveProperty);
set => SetValue(IsSelectAllActiveProperty, value);
}

public bool IsDropDownOpen
{
get => (bool) GetValue(IsDropDownOpenProperty);
get => (bool)GetValue(IsDropDownOpenProperty);
set => SetValue(IsDropDownOpenProperty, value);
}

public double MaxDropDownHeight
{
get => (double) GetValue(MaxDropDownHeightProperty);
get => (double)GetValue(MaxDropDownHeightProperty);
set => SetValue(MaxDropDownHeightProperty, value);
}

public IList SelectedItems
{
get => (IList) GetValue(SelectedItemsProperty);
get => (IList)GetValue(SelectedItemsProperty);
set => SetValue(SelectedItemsProperty, value);
}

public string SearchWatermark
{
get => (string) GetValue(SearchWatermarkProperty);
get => (string)GetValue(SearchWatermarkProperty);
set => SetValue(SearchWatermarkProperty, value);
}

Expand Down Expand Up @@ -236,18 +236,18 @@ public override void OnApplyTemplate()

private void Instance_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
SelectAllContent = LanguageManager.Instance["SelectAll"];
SelectAllContent = LanguageManager.Instance["SelectAll"];
}

private void OnListBoxSearch_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if ((bool) e.NewValue)
if ((bool)e.NewValue)
UpdateIsChecked(_listBoxSearch);
}

private void OnListBox_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if ((bool) e.NewValue)
if ((bool)e.NewValue)
{
foreach (var item in selectedSearchList)
if (!_listBox.SelectedItems.Contains(item))
Expand Down Expand Up @@ -277,7 +277,7 @@ private void UpdateIsChecked(ListBox listBox)

private void OnPopup_GotFocus(object sender, RoutedEventArgs e)
{
var source = (HwndSource) PresentationSource.FromVisual(_popup.Child);
var source = (HwndSource)PresentationSource.FromVisual(_popup.Child);
if (source != null)
{
SetFocus(source.Handle);
Expand Down Expand Up @@ -356,7 +356,17 @@ private void OnListBox_SelectionChanged(object sender, SelectionChangedEventArgs
if (e.AddedItems.Count > 0)
SelectionChecked(_listBox);
Combination();
SelectedItems = _listBox.SelectedItems;
var selectedItems = _listBox.SelectedItems;
if (SelectedItems == null)
SelectedItems = selectedItems;
else
{
foreach (var item in selectedItems)
{
if (!SelectedItems.Contains(item))
SelectedItems.Add(item);
}
}
}

private void OnListBoxSearch_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down Expand Up @@ -497,7 +507,7 @@ private static void OnIsDropDownOpenChanged(DependencyObject o, DependencyProper
{
var multiSelectionSearchComboBox = o as MultiSelectionSearchComboBox;
if (multiSelectionSearchComboBox != null)
multiSelectionSearchComboBox.OnIsOpenChanged((bool) e.OldValue, (bool) e.NewValue);
multiSelectionSearchComboBox.OnIsOpenChanged((bool)e.OldValue, (bool)e.NewValue);
}

protected virtual void OnIsOpenChanged(bool oldValue, bool newValue)
Expand All @@ -516,7 +526,7 @@ private static void OnMaxDropDownHeightChanged(DependencyObject o, DependencyPro
{
var comboBox = o as MultiSelectionSearchComboBox;
if (comboBox != null)
comboBox.OnMaxDropDownHeightChanged((double) e.OldValue, (double) e.NewValue);
comboBox.OnMaxDropDownHeightChanged((double)e.OldValue, (double)e.NewValue);
}

protected virtual void OnMaxDropDownHeightChanged(double oldValue, double newValue)
Expand Down

0 comments on commit 29e96ba

Please sign in to comment.