Search code examples
c#maui.net-mauimaui-windows

Horizontal Scroll is not working in MAUI. What am I missing or is this a bug?


If I make a brand new MAUI desktop app (using Visual Studio Version 17.3.0 Preview 4.0 or previous), I am unable to get horizontalscrollbar to show in ScrollView. If you've messed with MAUI, you know that when you make a new project, you get some canned content ("Cute dot net bot waving hi to you!"). Starting with that - the vertical scroll bar does show up as expected (see right side of attached image). enter image description here

But how to get the horizontal one to show up? I've cut out everything but the image (including the VerticalStackLayout and even added HorizontalScrollBarVisibility="Always"

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp1.MainPage">
    <ScrollView HorizontalScrollBarVisibility="Always">
        <Image
                Source="dotnet_bot.png"
                SemanticProperties.Description="Cute dot net bot waving hi to you!"
                 WidthRequest="800"
                 />
    </ScrollView>
</ContentPage>

but still no horizontal scroll. Any ideas? Is it a bug?

EDIT: Based on comment, I've changed the picture to be more clear...to show how the vertical scroll appears but the horizontal does not appear when the content is larger in both directions.


Solution

  • According to their answer at https://github.com/dotnet/maui/issues/9000 you can just add Orientation property on ScrollView.

    <ScrollView Orientation="Both" HorizontalScrollBarVisibility="Always">
    <Image 
        Source="dotnet_bot.png"
        SemanticProperties.Description="Cute dot net bot waving hi to you!"
        WidthRequest="800"/>
    </ScrollView>