WPF WrapPanel / ItemsControl 不滚动

发布于 2024-09-03 12:11:20 字数 849 浏览 2 评论 0原文

我有一个显示项目的环绕面板,但我无法让滚动条正常工作,有什么问题吗?

       <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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骑趴 2024-09-10 12:11:20

您的 ScrollViewer 位于 StackPanel 内部,它会根据其内容调整大小(垂直或水平取决于其方向)。将其直接放置在窗口、网格单元格或 DockPanel 中以显示滚动条。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文