@@ -79,7 +79,7 @@ public class MultiSelectionSearchComboBox : Control
79
79
80
80
public static readonly DependencyProperty SelectedItemsProperty =
81
81
DependencyProperty . Register ( "SelectedItems" , typeof ( IList ) , typeof ( MultiSelectionSearchComboBox ) ,
82
- new FrameworkPropertyMetadata ( null ,
82
+ new FrameworkPropertyMetadata ( new ArrayList ( ) ,
83
83
FrameworkPropertyMetadataOptions . BindsTwoWayByDefault | FrameworkPropertyMetadataOptions . Journal ,
84
84
OnSelectedItemsChanged ) ) ;
85
85
@@ -109,37 +109,37 @@ static MultiSelectionSearchComboBox()
109
109
110
110
public string Delimiter
111
111
{
112
- get => ( string ) GetValue ( DelimiterProperty ) ;
112
+ get => ( string ) GetValue ( DelimiterProperty ) ;
113
113
set => SetValue ( DelimiterProperty , value ) ;
114
114
}
115
115
116
116
public string SelectedValuePath
117
117
{
118
- get => ( string ) GetValue ( SelectedValuePathProperty ) ;
118
+ get => ( string ) GetValue ( SelectedValuePathProperty ) ;
119
119
set => SetValue ( SelectedValuePathProperty , value ) ;
120
120
}
121
121
122
122
public string DisplayMemberPath
123
123
{
124
- get => ( string ) GetValue ( DisplayMemberPathProperty ) ;
124
+ get => ( string ) GetValue ( DisplayMemberPathProperty ) ;
125
125
set => SetValue ( DisplayMemberPathProperty , value ) ;
126
126
}
127
127
128
128
public string Text
129
129
{
130
- get => ( string ) GetValue ( TextProperty ) ;
130
+ get => ( string ) GetValue ( TextProperty ) ;
131
131
set => SetValue ( TextProperty , value ) ;
132
132
}
133
133
134
134
public IEnumerable ItemsSource
135
135
{
136
- get => ( IEnumerable ) GetValue ( ItemsSourceProperty ) ;
136
+ get => ( IEnumerable ) GetValue ( ItemsSourceProperty ) ;
137
137
set => SetValue ( ItemsSourceProperty , value ) ;
138
138
}
139
139
140
140
public IEnumerable ItemsSourceSearch
141
141
{
142
- get => ( IEnumerable ) GetValue ( ItemsSourceSearchProperty ) ;
142
+ get => ( IEnumerable ) GetValue ( ItemsSourceSearchProperty ) ;
143
143
set => SetValue ( ItemsSourceSearchProperty , value ) ;
144
144
}
145
145
@@ -151,31 +151,31 @@ public object SelectAllContent
151
151
152
152
public bool IsSelectAllActive
153
153
{
154
- get => ( bool ) GetValue ( IsSelectAllActiveProperty ) ;
154
+ get => ( bool ) GetValue ( IsSelectAllActiveProperty ) ;
155
155
set => SetValue ( IsSelectAllActiveProperty , value ) ;
156
156
}
157
157
158
158
public bool IsDropDownOpen
159
159
{
160
- get => ( bool ) GetValue ( IsDropDownOpenProperty ) ;
160
+ get => ( bool ) GetValue ( IsDropDownOpenProperty ) ;
161
161
set => SetValue ( IsDropDownOpenProperty , value ) ;
162
162
}
163
163
164
164
public double MaxDropDownHeight
165
165
{
166
- get => ( double ) GetValue ( MaxDropDownHeightProperty ) ;
166
+ get => ( double ) GetValue ( MaxDropDownHeightProperty ) ;
167
167
set => SetValue ( MaxDropDownHeightProperty , value ) ;
168
168
}
169
169
170
170
public IList SelectedItems
171
171
{
172
- get => ( IList ) GetValue ( SelectedItemsProperty ) ;
172
+ get => ( IList ) GetValue ( SelectedItemsProperty ) ;
173
173
set => SetValue ( SelectedItemsProperty , value ) ;
174
174
}
175
175
176
176
public string SearchWatermark
177
177
{
178
- get => ( string ) GetValue ( SearchWatermarkProperty ) ;
178
+ get => ( string ) GetValue ( SearchWatermarkProperty ) ;
179
179
set => SetValue ( SearchWatermarkProperty , value ) ;
180
180
}
181
181
@@ -236,18 +236,18 @@ public override void OnApplyTemplate()
236
236
237
237
private void Instance_PropertyChanged ( object sender , PropertyChangedEventArgs e )
238
238
{
239
- SelectAllContent = LanguageManager . Instance [ "SelectAll" ] ;
239
+ SelectAllContent = LanguageManager . Instance [ "SelectAll" ] ;
240
240
}
241
241
242
242
private void OnListBoxSearch_IsVisibleChanged ( object sender , DependencyPropertyChangedEventArgs e )
243
243
{
244
- if ( ( bool ) e . NewValue )
244
+ if ( ( bool ) e . NewValue )
245
245
UpdateIsChecked ( _listBoxSearch ) ;
246
246
}
247
247
248
248
private void OnListBox_IsVisibleChanged ( object sender , DependencyPropertyChangedEventArgs e )
249
249
{
250
- if ( ( bool ) e . NewValue )
250
+ if ( ( bool ) e . NewValue )
251
251
{
252
252
foreach ( var item in selectedSearchList )
253
253
if ( ! _listBox . SelectedItems . Contains ( item ) )
@@ -277,7 +277,7 @@ private void UpdateIsChecked(ListBox listBox)
277
277
278
278
private void OnPopup_GotFocus ( object sender , RoutedEventArgs e )
279
279
{
280
- var source = ( HwndSource ) PresentationSource . FromVisual ( _popup . Child ) ;
280
+ var source = ( HwndSource ) PresentationSource . FromVisual ( _popup . Child ) ;
281
281
if ( source != null )
282
282
{
283
283
SetFocus ( source . Handle ) ;
@@ -356,7 +356,17 @@ private void OnListBox_SelectionChanged(object sender, SelectionChangedEventArgs
356
356
if ( e . AddedItems . Count > 0 )
357
357
SelectionChecked ( _listBox ) ;
358
358
Combination ( ) ;
359
- SelectedItems = _listBox . SelectedItems ;
359
+ var selectedItems = _listBox . SelectedItems ;
360
+ if ( SelectedItems == null )
361
+ SelectedItems = selectedItems ;
362
+ else
363
+ {
364
+ foreach ( var item in selectedItems )
365
+ {
366
+ if ( ! SelectedItems . Contains ( item ) )
367
+ SelectedItems . Add ( item ) ;
368
+ }
369
+ }
360
370
}
361
371
362
372
private void OnListBoxSearch_SelectionChanged ( object sender , SelectionChangedEventArgs e )
@@ -497,7 +507,7 @@ private static void OnIsDropDownOpenChanged(DependencyObject o, DependencyProper
497
507
{
498
508
var multiSelectionSearchComboBox = o as MultiSelectionSearchComboBox ;
499
509
if ( multiSelectionSearchComboBox != null )
500
- multiSelectionSearchComboBox . OnIsOpenChanged ( ( bool ) e . OldValue , ( bool ) e . NewValue ) ;
510
+ multiSelectionSearchComboBox . OnIsOpenChanged ( ( bool ) e . OldValue , ( bool ) e . NewValue ) ;
501
511
}
502
512
503
513
protected virtual void OnIsOpenChanged ( bool oldValue , bool newValue )
@@ -516,7 +526,7 @@ private static void OnMaxDropDownHeightChanged(DependencyObject o, DependencyPro
516
526
{
517
527
var comboBox = o as MultiSelectionSearchComboBox ;
518
528
if ( comboBox != null )
519
- comboBox . OnMaxDropDownHeightChanged ( ( double ) e . OldValue , ( double ) e . NewValue ) ;
529
+ comboBox . OnMaxDropDownHeightChanged ( ( double ) e . OldValue , ( double ) e . NewValue ) ;
520
530
}
521
531
522
532
protected virtual void OnMaxDropDownHeightChanged ( double oldValue , double newValue )
0 commit comments