Page 1 of 1

Inside ScrollViewer problem with ListBox ItemsPanel as WrapPanel

Posted: Sun Apr 03, 2016 4:19 am
by Vulten
If you set the ListBox.ItemsPanel to a WrapPanel nothing is shown if you place the entier ListBox inside a ScrollViewer. Outside the ScrollViewer it works fine.

Code: Select all

       
        <!--<ScrollViewer>-->
            <ListBox BorderThickness="2" BorderBrush="Black" Margin="3">
                <ListBoxItem Content=" Item1 x"/>
                <ListBoxItem Content=" Item2 x"/>
                <ListBoxItem Content=" Item3 x"/>
                <ListBoxItem Content=" Item4 x"/>
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>
        <!--</ScrollViewer>-->
       

Re: Inside ScrollViewer problem with ListBox ItemsPanel as WrapPanel

Posted: Mon Apr 04, 2016 9:13 am
by JS-Support @Userware
Dear Vulten,

Welcome to the forums and thank you for the bug report.

We have been able to reproduce it when placing the code inside a Grid (please let me know if you encounter the issue also when the code is placed inside something else).

We are going to attempt to fix it.

In the meantime, you may be able to work around it by placing the code in a different control such as a Border. Here is an example where I have created a new "Empty Application" project named "Application1", and placed the following code in MainPage.xaml:

Code: Select all

<Page
    x:Class="Application1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Application1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Border>
        <ScrollViewer>
            <ListBox BorderThickness="2" BorderBrush="Black" Margin="3">
                <ListBoxItem Content=" Item1 x"/>
                <ListBoxItem Content=" Item2 x"/>
                <ListBoxItem Content=" Item3 x"/>
                <ListBoxItem Content=" Item4 x"/>
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>
        </ScrollViewer>
    </Border>
</Page>


Thank you again.

Regards,
JS-Support