Skip to content

[FEATURE REQUEST] AvaloniaControls.AdvancedImageBox: Allow showing alternating grid background even when scroll bars are visible #1079

@Athari

Description

@Athari

Is your feature request related to a problem?

In the AdvancedImageBox control for Avalonia, alternating grid colors are disabled based on scroll bar visibility. This is due to this condition:

if (ShowGrid & gridCellSize > 0 && (!IsHorizontalBarVisible || !IsVerticalBarVisible))
{
// draw the background
var gridColor = GridColor;
var altColor = GridColorAlternate;
var currentColor = gridColor;
for (int y = 0; y < viewPortSize.Height; y += gridCellSize)
{
var firstRowColor = currentColor;
for (int x = 0; x < viewPortSize.Width; x += gridCellSize)
{
context.FillRectangle(currentColor, new Rect(x, y, gridCellSize, gridCellSize));
currentColor = ReferenceEquals(currentColor, gridColor) ? altColor : gridColor;
}
if (Equals(firstRowColor, currentColor))
currentColor = ReferenceEquals(currentColor, gridColor) ? altColor : gridColor;
}
}

I don't know what the reasoning is, but I find this behavior rather surprising as I don't expect background to change based on scroll bar visibility.

Describe the solution you'd like

Allow showing alternating grid background no matter the state of scroll bars.

If the app relies on this behavior, it can be achieved by binding ShowGrid or GridCellSize to !(IsHorizontalBarVisible && IsVerticalBarVisible) condition.

Files

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions