From 9169f04bbc530d995683b3dd85f676d5be52ba5a Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Thu, 12 Sep 2024 14:29:02 -0600 Subject: [PATCH] Fixes for virtualization with our use of the TreeDataGrid (#2038) --- .../Controls/TreeDataGrid/CustomElementFactory.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/NexusMods.App.UI/Controls/TreeDataGrid/CustomElementFactory.cs b/src/NexusMods.App.UI/Controls/TreeDataGrid/CustomElementFactory.cs index bf271c358..505a102b9 100644 --- a/src/NexusMods.App.UI/Controls/TreeDataGrid/CustomElementFactory.cs +++ b/src/NexusMods.App.UI/Controls/TreeDataGrid/CustomElementFactory.cs @@ -41,9 +41,11 @@ protected override string GetDataRecycleKey(object? data) switch (data) { - case IIndentedRow: + case IIndentedRow { Indent: 0 }: + { var rowKey = $"{base.GetDataRecycleKey(data)}|{RootRowClass}"; return string.Intern(rowKey); + } case ICustomCell customCell: { // NOTE(Al12rs): the keys generated here should match the ones in GetElementRecycleKey, ensure order and format is the same @@ -63,7 +65,7 @@ protected override string GetElementRecycleKey(Control element) var sb = new StringBuilder(value: base.GetElementRecycleKey(element)); - if (element is not TreeDataGridCell or TreeDataGridRow) + if (element is not TreeDataGridCell and not TreeDataGridRow) return string.Intern(sb.ToString()); // NOTE(Al12rs): Order here should match the insertion order in CreateElement, first the id, then the RootRowClass