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> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="0.6.2-build5521-beta" /> <PackageReference Include="Avalonia" Version="0.6.2-build5800-beta" />
<PackageReference Include="Avalonia.Desktop" Version="0.6.2-build5521-beta" /> <PackageReference Include="Avalonia.Desktop" Version="0.6.2-build5800-beta" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Avalonia.DataGrid.Themes.Default\Avalonia.DataGrid.Themes.Default.csproj" /> <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> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="0.6.2-build5521-beta" /> <PackageReference Include="Avalonia" Version="0.6.2-build5800-beta" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="**\*.xaml.cs"> <Compile Update="**\*.xaml.cs">

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

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

8
src/Avalonia.DataGrid/DataGrid.cs

@ -1512,7 +1512,7 @@ namespace Avalonia.Controls
{ {
get get
{ {
return RowsPresenterAvailableSize?.Height ?? 0; return RowsPresenterEstimatedAvailableHeight ?? 0;
} }
} }
@ -1800,7 +1800,11 @@ namespace Avalonia.Controls
_rowsPresenterAvailableSize = value; _rowsPresenterAvailableSize = value;
} }
} }
internal double? RowsPresenterEstimatedAvailableHeight
{
get;
set;
}
internal double[] RowGroupSublevelIndents 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 // Do these even if the OwningGrid is null in case it could improve the Designer experience for a standalone DataGridRowGroupHeader
RowGroupInfo.IsVisible = isVisible; RowGroupInfo.IsVisible = isVisible;
} }
else else if(RowGroupInfo.IsVisible != isVisible)
{ {
OwningGrid.OnRowGroupHeaderToggled(this, isVisible, setCurrent); OwningGrid.OnRowGroupHeaderToggled(this, isVisible, setCurrent);
} }

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

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

Loading…
Cancel
Save