@@ -116,9 +116,7 @@ private void UpdateSource()
116116 foreach ( var c in model . SelectedItems )
117117 CollectChangesInNode ( selected , c ) ;
118118
119- _isSelecting = true ;
120- SetCurrentValue ( SelectedChangesProperty , selected ) ;
121- _isSelecting = false ;
119+ TrySetSelected ( selected ) ;
122120 }
123121 } ;
124122
@@ -144,9 +142,7 @@ private void UpdateSource()
144142 foreach ( var c in model . SelectedItems )
145143 selected . Add ( c ) ;
146144
147- _isSelecting = true ;
148- SetCurrentValue ( SelectedChangesProperty , selected ) ;
149- _isSelecting = false ;
145+ TrySetSelected ( selected ) ;
150146 }
151147 } ;
152148
@@ -172,9 +168,7 @@ private void UpdateSource()
172168 foreach ( var c in model . SelectedItems )
173169 selected . Add ( c ) ;
174170
175- _isSelecting = true ;
176- SetCurrentValue ( SelectedChangesProperty , selected ) ;
177- _isSelecting = false ;
171+ TrySetSelected ( selected ) ;
178172 }
179173 } ;
180174
@@ -269,6 +263,34 @@ private void CollectSelectedNodeByChange(List<Models.FileTreeNode> outs, Models.
269263 }
270264 }
271265
266+ private void TrySetSelected ( List < Models . Change > changes )
267+ {
268+ var old = SelectedChanges ;
269+
270+ if ( old == null && changes . Count == 0 )
271+ return ;
272+
273+ if ( old != null && old . Count == changes . Count )
274+ {
275+ bool allEquals = true ;
276+ foreach ( var c in old )
277+ {
278+ if ( ! changes . Contains ( c ) )
279+ {
280+ allEquals = false ;
281+ break ;
282+ }
283+ }
284+
285+ if ( allEquals )
286+ return ;
287+ }
288+
289+ _isSelecting = true ;
290+ SetCurrentValue ( SelectedChangesProperty , changes ) ;
291+ _isSelecting = false ;
292+ }
293+
272294 private bool _isSelecting = false ;
273295 }
274296}
0 commit comments