简体   繁体   中英

WPF WrapPanel / ItemsControl not scrolling

I have a wrap panel displaying items but I cant get a scroll bar to work properly any idea's whats wrong ?

       <ScrollViewer>
        <ItemsControl Name="itemsControl">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel ItemWidth="{Binding ElementName=sizeSlider, Path=Value}" 
                                   FlowDirection="LeftToRight"  Height="auto" Width="auto"
                                   HorizontalAlignment="Left" Name="wrapPanel1" 
                                   VerticalAlignment="Top"
                                   Margin="5"
                               >
                    </WrapPanel>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
    </ScrollViewer>
</StackPanel>

Your ScrollViewer is inside StackPanel which resizes to its content (either vertically or horizontally depending on its orientation). Place it either directly in a Window, a cell of a Grid, or a DockPanel for scroll bars to show up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM