|
|
|
@ -39,6 +39,7 @@ namespace Avalonia.Controls |
|
|
|
private const string DATAGRID_elementRowHeadersPresenterName = "PART_RowHeadersPresenter"; |
|
|
|
private const string DATAGRID_elementTopLeftCornerHeaderName = "PART_TopLeftCornerHeader"; |
|
|
|
private const string DATAGRID_elementTopRightCornerHeaderName = "PART_TopRightCornerHeader"; |
|
|
|
private const string DATAGRID_elementBottomRightCornerHeaderName = "PART_BottomRightCorner"; |
|
|
|
private const string DATAGRID_elementValidationSummary = "PART_ValidationSummary"; |
|
|
|
private const string DATAGRID_elementVerticalScrollbarName = "PART_VerticalScrollbar"; |
|
|
|
|
|
|
|
@ -79,6 +80,7 @@ namespace Avalonia.Controls |
|
|
|
private INotifyCollectionChanged _topLevelGroup; |
|
|
|
private ContentControl _clipboardContentControl; |
|
|
|
|
|
|
|
private IVisual _bottomRightCorner; |
|
|
|
private DataGridColumnHeadersPresenter _columnHeadersPresenter; |
|
|
|
private DataGridRowsPresenter _rowsPresenter; |
|
|
|
private ScrollBar _vScrollBar; |
|
|
|
@ -1825,6 +1827,22 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private bool IsHorizontalScrollBarOverCells |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
return _columnHeadersPresenter != null && Grid.GetColumnSpan(_columnHeadersPresenter) == 2; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private bool IsVerticalScrollBarOverCells |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
return _rowsPresenter != null && Grid.GetRowSpan(_rowsPresenter) == 2; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private int NoSelectionChangeCount |
|
|
|
{ |
|
|
|
get |
|
|
|
@ -2323,6 +2341,7 @@ namespace Avalonia.Controls |
|
|
|
_topLeftCornerHeader = e.NameScope.Find<ContentControl>(DATAGRID_elementTopLeftCornerHeaderName); |
|
|
|
EnsureTopLeftCornerHeader(); // EnsureTopLeftCornerHeader checks for a null _topLeftCornerHeader;
|
|
|
|
_topRightCornerHeader = e.NameScope.Find<ContentControl>(DATAGRID_elementTopRightCornerHeaderName); |
|
|
|
_bottomRightCorner = e.NameScope.Find<IVisual>(DATAGRID_elementBottomRightCornerHeaderName); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -3293,6 +3312,10 @@ namespace Avalonia.Controls |
|
|
|
//
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
bool isHorizontalScrollBarOverCells = IsHorizontalScrollBarOverCells; |
|
|
|
bool isVerticalScrollBarOverCells = IsVerticalScrollBarOverCells; |
|
|
|
|
|
|
|
double cellsWidth = CellsWidth; |
|
|
|
double cellsHeight = CellsHeight; |
|
|
|
|
|
|
|
@ -3308,10 +3331,17 @@ namespace Avalonia.Controls |
|
|
|
// Compensate if the horizontal scrollbar is already taking up space
|
|
|
|
if (!forceHorizScrollbar && _hScrollBar.IsVisible) |
|
|
|
{ |
|
|
|
cellsHeight += _hScrollBar.DesiredSize.Height; |
|
|
|
if (!isHorizontalScrollBarOverCells) |
|
|
|
{ |
|
|
|
cellsHeight += _hScrollBar.DesiredSize.Height; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!isHorizontalScrollBarOverCells) |
|
|
|
{ |
|
|
|
horizScrollBarHeight = _hScrollBar.Height + _hScrollBar.Margin.Top + _hScrollBar.Margin.Bottom; |
|
|
|
} |
|
|
|
horizScrollBarHeight = _hScrollBar.Height + _hScrollBar.Margin.Top + _hScrollBar.Margin.Bottom; |
|
|
|
} |
|
|
|
|
|
|
|
bool allowVertScrollbar = false; |
|
|
|
bool forceVertScrollbar = false; |
|
|
|
double vertScrollBarWidth = 0; |
|
|
|
@ -3324,9 +3354,15 @@ namespace Avalonia.Controls |
|
|
|
// Compensate if the vertical scrollbar is already taking up space
|
|
|
|
if (!forceVertScrollbar && _vScrollBar.IsVisible) |
|
|
|
{ |
|
|
|
cellsWidth += _vScrollBar.DesiredSize.Width; |
|
|
|
if (!isVerticalScrollBarOverCells) |
|
|
|
{ |
|
|
|
cellsWidth += _vScrollBar.DesiredSize.Width; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!isVerticalScrollBarOverCells) |
|
|
|
{ |
|
|
|
vertScrollBarWidth = _vScrollBar.Width + _vScrollBar.Margin.Left + _vScrollBar.Margin.Right; |
|
|
|
} |
|
|
|
vertScrollBarWidth = _vScrollBar.Width + _vScrollBar.Margin.Left + _vScrollBar.Margin.Right; |
|
|
|
} |
|
|
|
|
|
|
|
// Now cellsWidth is the width potentially available for displaying data cells.
|
|
|
|
@ -3354,7 +3390,9 @@ namespace Avalonia.Controls |
|
|
|
cellsHeight -= horizScrollBarHeight; |
|
|
|
Debug.Assert(cellsHeight >= 0); |
|
|
|
needHorizScrollbarWithoutVertScrollbar = needHorizScrollbar = true; |
|
|
|
if (allowVertScrollbar && (MathUtilities.LessThanOrClose(totalVisibleWidth - cellsWidth, vertScrollBarWidth) || |
|
|
|
|
|
|
|
if (vertScrollBarWidth > 0 && |
|
|
|
allowVertScrollbar && (MathUtilities.LessThanOrClose(totalVisibleWidth - cellsWidth, vertScrollBarWidth) || |
|
|
|
MathUtilities.LessThanOrClose(cellsWidth - totalVisibleFrozenWidth, vertScrollBarWidth))) |
|
|
|
{ |
|
|
|
// Would we still need a horizontal scrollbar without the vertical one?
|
|
|
|
@ -3372,7 +3410,12 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
UpdateDisplayedRows(DisplayData.FirstScrollingSlot, cellsHeight); |
|
|
|
// Store the current FirstScrollingSlot because removing the horizontal scrollbar could scroll
|
|
|
|
// the DataGrid up; however, if we realize later that we need to keep the horizontal scrollbar
|
|
|
|
// then we should use the first slot stored here which is not scrolled.
|
|
|
|
int firstScrollingSlot = DisplayData.FirstScrollingSlot; |
|
|
|
|
|
|
|
UpdateDisplayedRows(firstScrollingSlot, cellsHeight); |
|
|
|
if (allowVertScrollbar && |
|
|
|
MathUtilities.GreaterThan(cellsHeight, 0) && |
|
|
|
MathUtilities.LessThanOrClose(vertScrollBarWidth, cellsWidth) && |
|
|
|
@ -3384,10 +3427,12 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
|
|
|
|
DisplayData.FirstDisplayedScrollingCol = ComputeFirstVisibleScrollingColumn(); |
|
|
|
|
|
|
|
// we compute the number of visible columns only after we set up the vertical scroll bar.
|
|
|
|
ComputeDisplayedColumns(); |
|
|
|
|
|
|
|
if (allowHorizScrollbar && |
|
|
|
if ((vertScrollBarWidth > 0 || horizScrollBarHeight > 0) && |
|
|
|
allowHorizScrollbar && |
|
|
|
needVertScrollbar && !needHorizScrollbar && |
|
|
|
MathUtilities.GreaterThan(totalVisibleWidth, cellsWidth) && |
|
|
|
MathUtilities.LessThan(totalVisibleFrozenWidth, cellsWidth) && |
|
|
|
@ -3398,7 +3443,7 @@ namespace Avalonia.Controls |
|
|
|
Debug.Assert(cellsHeight >= 0); |
|
|
|
needVertScrollbar = false; |
|
|
|
|
|
|
|
UpdateDisplayedRows(DisplayData.FirstScrollingSlot, cellsHeight); |
|
|
|
UpdateDisplayedRows(firstScrollingSlot, cellsHeight); |
|
|
|
if (cellsHeight > 0 && |
|
|
|
vertScrollBarWidth <= cellsWidth && |
|
|
|
DisplayData.NumTotallyDisplayedScrollingElements != VisibleSlotCount) |
|
|
|
@ -3479,6 +3524,15 @@ namespace Avalonia.Controls |
|
|
|
_topRightCornerHeader.IsVisible = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (_bottomRightCorner != null) |
|
|
|
{ |
|
|
|
// Show the BottomRightCorner when both scrollbars are visible.
|
|
|
|
_bottomRightCorner.IsVisible = |
|
|
|
_hScrollBar != null && _hScrollBar.IsVisible && |
|
|
|
_vScrollBar != null && _vScrollBar.IsVisible; |
|
|
|
} |
|
|
|
|
|
|
|
DisplayData.FullyRecycleElements(); |
|
|
|
} |
|
|
|
|
|
|
|
|