Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScrollView control doesn't scoll. #9373

Closed
Simon-IT opened this issue Feb 29, 2024 · 6 comments
Closed

ScrollView control doesn't scoll. #9373

Simon-IT opened this issue Feb 29, 2024 · 6 comments
Labels
area-Scrolling bug Something isn't working needs-triage Issue needs to be triaged by the area owners team-Controls Issue for the Controls team

Comments

@Simon-IT
Copy link

Simon-IT commented Feb 29, 2024

Describe the bug

Hi,
creating a very simple C# WinUI 3 desktop app for text scrolling test, I've found a problem if a TextBlock control contained in a ScrollView control are inside a Grid and its row position is not 0: simply in position 1 the vertical scroll bar doesn't appear and so scrolling is impossible.
Thank you for the time !!

Steps to reproduce the bug

  1. Create a simple WinUI 3 C# Desktop app.
  2. In MainWindow.xaml file sets the Window content as:
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="240"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <!-- Use Grid.Row values between 0 (works) and 1 (doesn't work) to see the behaviour -->
    <ScrollView Margin="16" Grid.Row="1">
        <TextBlock TextWrapping="WrapWholeWords">
            TextBlock is the primary control for displaying read-only text in apps. 
            You can use it to display single-line or multi-line text, inline hyperlinks, 
            and text with formatting like bold, italic, or underlined.
            TextBlock is typically easier to use and provides better text rendering 
            performance than RichTextBlock, so it's preferred for most app UI text. 
            It also provides many of the same formatting options for customizing how your 
            text is rendered. Although you can put line breaks in the text, TextBlock is 
            designed to display a single paragraph and doesn't support text indentation. 
            Consider a RichTextBlock if you need support for multiple paragraphs, multi-column text, 
            or inline UI elements like images.
        </TextBlock>
    </ScrollView>
</Grid>
  1. Resize the window until the viewport doesn't contain all the text

Expected behavior

Vertical scroll bar should appears in both 0 and 1 grid position

Screenshots

image

NuGet package version

None

Windows version

No response

Additional context

WinUI 3 - WindowsApp SDK 1.4.5: 1.4.240211001
Windows 11 23H2: Build 22631.3155

@Simon-IT Simon-IT added the bug Something isn't working label Feb 29, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 29, 2024
Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Open similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@eduardobragaxz
Copy link

Try RowDefinition Height="*" instead of Auto.

@Simon-IT
Copy link
Author

Thank you @eduardobragaxz with "*" it works. But, in your opinion, is It a correct behaviour ? Why in row 0 it works ?

@kmgallahan
Copy link
Contributor

kmgallahan commented Feb 29, 2024

@Simon-IT Which row it is in doesn't matter.

If you put something in a row with Auto as the height, the row will grow to whatever size the content wants. The ScrollView wants to be as big as its content (the TextBlock), so the grid lets it be that big (hence no scrolling). The row is now running off the bottom of the screen.

If you put something in a row with * as the height the row stretches to fill however much space it can, then tells its children that is how much space they have to work with. The ScrollView now doesn't get to be as big as it wants, so its height is constrained and scrolling now works.

Setting the height to 240 is the same as *, you just provided an explicit height rather than a variable one based on the containing elements.

@bpulliam bpulliam added area-Scrolling team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Feb 29, 2024
@ranjeshj
Copy link
Contributor

ranjeshj commented Mar 7, 2024

Thanks @kmgallahan for the detailed response. @Simon-IT hope that helps.

@ranjeshj ranjeshj closed this as completed Mar 7, 2024
@Simon-IT
Copy link
Author

Simon-IT commented Mar 8, 2024

@Thak you @kmgallahan for the detailed response. Thank you all guys for time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Scrolling bug Something isn't working needs-triage Issue needs to be triaged by the area owners team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

5 participants