Skip to content

Scrollbars of ScrollViewer around ZoomBorder don't seem to work correctly if VerticalAlignment and HorizontalAlignment aren't set to Top/Left #132

@greenwaym

Description

@greenwaym

If VerticalAlignment and HorizonalAlignment are set to Stretch, then the Scroll bars of the Scrollviewer surrounding the Zoomborder don't allow scrolling to the whole content, but instead the content is cut off. This doesn't happen when VerticalAlignment is set to "Top" and HorizontalAlignment is set to "Left".

Minimal Example to reproduce the issue:

<Window x:Class="PanAndZoomTests.Views.MainWindow"
        xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:paz="using:Avalonia.Controls.PanAndZoom"
        WindowStartupLocation="CenterScreen" UseLayoutRounding="True"
        Title="PanAndZoom" Height="640" Width="640">
        <ScrollViewer VerticalScrollBarVisibility="Auto"
                      HorizontalScrollBarVisibility="Auto" 
                      Background="Red">
            <paz:ZoomBorder Name="ZoomBorder" 
                            Stretch="None" 
                            ZoomSpeed="1.2"
                            Background="SlateBlue" 
                            ClipToBounds="True" 
                            Focusable="True"
                            VerticalAlignment="Stretch" 
                            HorizontalAlignment="Stretch">
                <Border Width="800" Height="600" BorderThickness="2" BorderBrush="Black" Background="Wheat"/>
                
            </paz:ZoomBorder>  
        </ScrollViewer>
</Window>

Here we just have the ZoomBorder with a simple Border control as content. When we set VerticalAlignment="Stretch" and HorizontalAlignment="Stretch"> on ZoomBorder, the Scrollbars of the ScrollViewer don't allow to correctly scroll the full content. This is visible as my border control is a black border brush in this example, thus when panning using the scroll bars, it should be possible to see the border brush on all sides. That is not the case.

Potential reason:

Is it possible that when the bounds are calculated in ZoomBorder, that the position of the content in Zoomborder is assumed to be 0,0? This is the case with Alignment set to top, left, as the ZoomBorder then just becomes the size of it's child component. The Child component seems to be centered as the ZoomBorder behaves like a border. So as soon as ZoomBorder isn't the same size as it's content, due to stretch ( or a specified size ), then the position of the child component isn't 0,0 anymore, but rather will have an offset due to the centering.

After further testing, the issue seems to be far more widespread then just regarding the Scrollbars. It seems to also effect Content Bounds Restriction with BoundsMode, and potentially any other operations that rely on correct bounds calculations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions