WPF WrapPanel/ItemsControl不滚动

Kay*_*aya 8 wpf wrappanel scrollviewer

我有一个显示项目的包装面板,但我不能让滚动条正常工作任何想法的错误是什么?

       <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>
Run Code Online (Sandbox Code Playgroud)

rep*_*pka 12

您的ScrollViewer位于StackPanel内部,可调整其内容(垂直或水平,具体取决于其方向).将其直接放在窗口,网格单元格或DockPanel中,以显示滚动条.