Browse Source

Fixes scrolling bug in grouped DataGrids

Fixes #5
pull/2109/head
sdoroff 8 years ago
parent
commit
f24b7da0d3
  1. 4
      samples/DataGridSample/DataGridSample.csproj
  2. 2
      src/Avalonia.DataGrid.Themes.Default/Avalonia.DataGrid.Themes.Default.csproj
  3. 2
      src/Avalonia.DataGrid/Avalonia.DataGrid.csproj
  4. 8
      src/Avalonia.DataGrid/DataGrid.cs
  5. 2
      src/Avalonia.DataGrid/DataGridRowGroupHeader.cs
  6. 26
      src/Avalonia.DataGrid/Primitives/DataGridRowsPresenter.cs

4
samples/DataGridSample/DataGridSample.csproj

@ -12,8 +12,8 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.6.2-build5521-beta" />
<PackageReference Include="Avalonia.Desktop" Version="0.6.2-build5521-beta" />
<PackageReference Include="Avalonia" Version="0.6.2-build5800-beta" />
<PackageReference Include="Avalonia.Desktop" Version="0.6.2-build5800-beta" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Avalonia.DataGrid.Themes.Default\Avalonia.DataGrid.Themes.Default.csproj" />

2
src/Avalonia.DataGrid.Themes.Default/Avalonia.DataGrid.Themes.Default.csproj

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.6.2-build5521-beta" />
<PackageReference Include="Avalonia" Version="0.6.2-build5800-beta" />
</ItemGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">

2
src/Avalonia.DataGrid/Avalonia.DataGrid.csproj

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.6.2-build5521-beta" />
<PackageReference Include="Avalonia" Version="0.6.2-build5800-beta" />
</ItemGroup>
</Project>

8
src/Avalonia.DataGrid/DataGrid.cs

@ -1512,7 +1512,7 @@ namespace Avalonia.Controls
{
get
{
return RowsPresenterAvailableSize?.Height ?? 0;
return RowsPresenterEstimatedAvailableHeight ?? 0;
}
}
@ -1800,7 +1800,11 @@ namespace Avalonia.Controls
_rowsPresenterAvailableSize = value;
}
}
internal double? RowsPresenterEstimatedAvailableHeight
{
get;
set;
}
internal double[] RowGroupSublevelIndents
{

2
src/Avalonia.DataGrid/DataGridRowGroupHeader.cs

@ -468,7 +468,7 @@ namespace Avalonia.Controls
// Do these even if the OwningGrid is null in case it could improve the Designer experience for a standalone DataGridRowGroupHeader
RowGroupInfo.IsVisible = isVisible;
}
else
else if(RowGroupInfo.IsVisible != isVisible)
{
OwningGrid.OnRowGroupHeaderToggled(this, isVisible, setCurrent);
}

26
src/Avalonia.DataGrid/Primitives/DataGridRowsPresenter.cs

@ -20,7 +20,20 @@ namespace Avalonia.Controls.Primitives
get;
set;
}
private double _measureHeightOffset = 0;
private double CalculateEstimatedAvailableHeight(Size availableSize)
{
if(!Double.IsPositiveInfinity(availableSize.Height))
{
return availableSize.Height + _measureHeightOffset;
}
else
{
return availableSize.Height;
}
}
/// <summary>
/// Arranges the content of the <see cref="T:Avalonia.Controls.Primitives.DataGridRowsPresenter" />.
/// </summary>
@ -37,6 +50,16 @@ namespace Avalonia.Controls.Primitives
return base.ArrangeOverride(finalSize);
}
if(OwningGrid.RowsPresenterAvailableSize.HasValue)
{
var availableHeight = OwningGrid.RowsPresenterAvailableSize.Value.Height;
if(!Double.IsPositiveInfinity(availableHeight))
{
_measureHeightOffset = finalSize.Height - availableHeight;
OwningGrid.RowsPresenterEstimatedAvailableHeight = finalSize.Height;
}
}
OwningGrid.OnFillerColumnWidthNeeded(finalSize.Width);
double rowDesiredWidth = OwningGrid.ColumnsInternal.VisibleEdgedColumnsWidth + OwningGrid.ColumnsInternal.FillerColumn.FillerWidth;
@ -97,6 +120,7 @@ namespace Avalonia.Controls.Primitives
// The DataGrid uses the RowsPresenter available size in order to autogrow
// and calculate the scrollbars
OwningGrid.RowsPresenterAvailableSize = availableSize;
OwningGrid.RowsPresenterEstimatedAvailableHeight = CalculateEstimatedAvailableHeight(availableSize);
OwningGrid.OnRowsMeasure();

Loading…
Cancel
Save