New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UWP DataGrid.RowDetailsVisibilityMode.VisibleWhenSelected performance issue #2842
Comments
I have done some performance analysis and implemented an experimental code change that at least works for our scenario. The code causing bad performance is in if (height > 2 * this.CellsHeight &&
(this.RowDetailsVisibilityMode != DataGridRowDetailsVisibilityMode.VisibleWhenSelected || this.RowDetailsTemplate == null Consequently, the large scroll optimization is by-passed for I have implemented an experimental code change, that works well at least in our usage scenario: When there is a large scroll, we calculate an average Row Detail Height, see Here follows the code change (only implemented for the 'scrolling down' case): if (height > 2 * this.CellsHeight /* ORIG CODE: &&
(this.RowDetailsVisibilityMode != DataGridRowDetailsVisibilityMode.VisibleWhenSelected || this.RowDetailsTemplate == null */)
{
// Very large scroll occurred. Instead of determining the exact number of scrolled off rows,
// let's estimate the number based on this.RowHeight.
/* ORIG CODE:
ResetDisplayedRows();
double singleRowHeightEstimate = this.RowHeightEstimate + (this.RowDetailsVisibilityMode == DataGridRowDetailsVisibilityMode.Visible ? this.RowDetailsHeightEstimate : 0);
int scrolledToSlot = newFirstScrollingSlot + (int)(height / singleRowHeightEstimate);
scrolledToSlot += _collapsedSlotsTable.GetIndexCount(newFirstScrollingSlot, newFirstScrollingSlot + scrolledToSlot);
newFirstScrollingSlot = Math.Min(GetNextVisibleSlot(scrolledToSlot), lastVisibleSlot);
*/
// NEW CODE Start
double averageRowDetailHeight()
{
double result = 0;
switch (this.RowDetailsVisibilityMode)
{
case DataGridRowDetailsVisibilityMode.Collapsed:
result = 0;
break;
case DataGridRowDetailsVisibilityMode.Visible:
result = this.RowDetailsHeightEstimate;
break;
case DataGridRowDetailsVisibilityMode.VisibleWhenSelected:
if (this.RowDetailsTemplate == null)
{
result = 0;
}
else
{
int totalRows = this.DataConnection.Count;
int totalOpenRowDetails = GetDetailsCountInclusive(0, totalRows);
result = this.RowDetailsHeightEstimate * ((double)totalOpenRowDetails / totalRows);
}
break;
default:
break; // Error, cannot happen
}
return result;
}
ResetDisplayedRows();
double singleRowHeightEstimate = this.RowHeightEstimate + averageRowDetailHeight();
int scrolledToSlot = newFirstScrollingSlot + (int)(height / singleRowHeightEstimate);
scrolledToSlot += _collapsedSlotsTable.GetIndexCount(newFirstScrollingSlot, newFirstScrollingSlot + scrolledToSlot);
newFirstScrollingSlot = Math.Min(GetNextVisibleSlot(scrolledToSlot), lastVisibleSlot);
// NEW CODE End |
We are not adding features to this DataGrid at this time. See possible workaround above. If you would like to see this feature in the newly proposed WinUI DataGrid, please add a comment in the WinUI discussion issue. Thanks! |
Closing this issue as this is already responded by @anawishnoff |
I'm submitting a...
Bug report (I searched for similar issues and did not find one)
See reproduction of issue at this github bug repro:
DataGridRowDetailsPerfTest
Current behavior
Scrolling performance degrades dramatically when the
DataGrid
propertyRowDetailsVisibilityMode
is set toVisibleWhenSelected
. There is no issue when it is set toCollapsed
orVisible
. I have tested this with a relatively modest datagrid of 20,000 items, which should pose no issue with a UI virtualized datagrid.Expected behavior
Smooth scrolling performance regardless of which
RowDetailsVisibilityMode
is chosen.Minimal reproduction of the problem with instructions
There is a minimal repro here:
DataGridRowDetailsPerfTest
Environment
Nuget Package(s):
Package Version(s):
Windows 10 Build Number:
App min and target version:
Device form factor:
Visual Studio
The text was updated successfully, but these errors were encountered: