question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextWrapping doesn't work inside of a ScrollViewer

See original GitHub issue

MCVE

xaml

<ScrollViewer>
    <ItemsRepeater Items="{Binding Items}">
        <ItemsRepeater.ItemTemplate>
            <DataTemplate>
                <Grid ColumnDefinitions="*, Auto">
                    <TextBlock
                        Grid.Column="0"
                        Text="{Binding Text}"
                        TextWrapping="Wrap" />
                    <TextBlock Grid.Column="1" Text="{Binding Id}" />
                </Grid>
            </DataTemplate>
        </ItemsRepeater.ItemTemplate>
    </ItemsRepeater>
</ScrollViewer>

context:

public MainWindow()
{
            
    Items = new SomeType[]
    {
        new SomeType(@"Welcome to Avalonia! Avalonia is a cross platform XAML Framework for .NET Framework, .NET Core and Mono. 
Avalonia is shipped as .NET standard 2.0 NuGet packages and a set of templates for Visual Studio and .NET core. We also have a visual designer for Visual Studio.
This page is designed as a whirlwind tour of Avalonia. There are plenty of links throughout to more detailed documentation on each area, or you can navigate using the sections on the left.", 0),
        new SomeType(@"Avalonia lets you develop an appliction using the XAML markup language and C# (or another .NET language) for code. You generally use XAML markup to implement the appearance of an application while using code to implement its behavior.", 1),
        new SomeType(@"XAML is an XML-based markup language that implements an application's appearance declaratively. You typically use it to create windows and user controls, and to fill them with controls, shapes, and graphics.
The following example uses XAML to implement the appearance of a window that contains a single button", 2)
    };
    AvaloniaXamlLoader.Load(this);
    DataContext = this;
}

public IEnumerable<SomeType> Items { get; }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
FoggyFindercommented, Sep 2, 2020

Thanks. Works fine with

ScrollViewer.HorizontalScrollBarVisibility="Disabled"
1reaction
Gillibaldcommented, Sep 1, 2020

If it is not disabled the content is measured with infinite space. That prevents text wrapping. It is worth a try to disable horizontal scrolling.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ScrollViewer and TextBlock wrapping - wpf
How can I achieve this in xaml? It seems that as soon as ScrollViewer is inserted, TextBlock does not wrap any more. wpf...
Read more >
How to get WPF ScrollViewer to automaticall scroll ...
In XAML I have a WPF TextBlock inside of a ScrollViewer. I would like the ScrollViewer to automatically scroll the TextBlock contents so ......
Read more >
ScrollViewer Overview - WPF .NET Framework
The ScrollViewer control provides a convenient way to enable scrolling of content in Windows Presentation Foundation (WPF) applications.
Read more >
Scrolling entire elements problem in UI for WPF
Hello, Indeed the explained behavior is caused by the different Heights of the ListBoxItems - a single item is always scrolled to top...
Read more >
Implementing Scrolling in Windows using WPF ...
The simplest way to enable scrolling on a content control is by placing the content control inside a ScrollViewer control. The following code ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found