Skip to content

Commit 5dbb529

Browse files
committed
enhance: prevent too many selection changed events being raised while apply selection to commit list
Signed-off-by: leo <longshuang@msn.cn>
1 parent baf0dd0 commit 5dbb529

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎src/Views/Histories.axaml.cs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Reflection;
34
using System.Text;
45
using System.Threading.Tasks;
56

@@ -189,14 +190,36 @@ private void ApplySelection()
189190
}
190191
else
191192
{
193+
IncrNoSelectionChangeCount();
192194
SelectedItems.Clear();
193195
foreach (var c in SelectedCommits)
194196
SelectedItems.Add(c);
197+
DecrNoSelectionChangeCount();
195198
}
196199

197200
_ignoreSelectionChanged = false;
198201
}
199202

203+
private void IncrNoSelectionChangeCount()
204+
{
205+
var property = typeof(DataGrid).GetProperty("NoSelectionChangeCount", BindingFlags.Instance | BindingFlags.NonPublic);
206+
if (property != null)
207+
{
208+
var old = (int)property.GetValue(this);
209+
property.SetValue(this, old + 1);
210+
}
211+
}
212+
213+
private void DecrNoSelectionChangeCount()
214+
{
215+
var property = typeof(DataGrid).GetProperty("NoSelectionChangeCount", BindingFlags.Instance | BindingFlags.NonPublic);
216+
if (property != null)
217+
{
218+
var old = (int)property.GetValue(this);
219+
property.SetValue(this, old - 1);
220+
}
221+
}
222+
200223
private bool _ignoreSelectionChanged = false;
201224
}
202225

0 commit comments

Comments
 (0)