列表框中的垂直滚动

发布于 2024-12-10 16:15:57 字数 618 浏览 2 评论 0原文

您好,我在网格内有一个如下所示的列表框。当项目数量超过列表框的高度时,我无法使列表框内的项目可滚动。

我将 VerticalScrollBarVisibility="Visible" 添加到 ListBox 标记,但它根本不起作用。

阅读有关滚动在堆栈面板中不起作用的地方。

任何人都可以帮我解决这个问题吗?提前致谢!

<ListBox>
    <TreeView>
       <TreeView.Resources>
           <HierarchicalDataTemplate>
               <StackPanel>
                 <TextBlock />
                 <TextBox></TextBox>
               </StackPanel>
           </HierarchicalDataTemplate>
       </TreeView.Resources>
    </TreeView>
</ListBox>

Hi I have a list box as below inside a grid. I cant make the items inside the ListBox scrollable when the number of items exceed the height of the ListBox.

I added VerticalScrollBarVisibility="Visible" to the ListBox tag but it doesn't work at all.

Read somewhere about scrolling doesnt work in a stack panel.

Anyone can help me with this? Thanks in advance!

<ListBox>
    <TreeView>
       <TreeView.Resources>
           <HierarchicalDataTemplate>
               <StackPanel>
                 <TextBlock />
                 <TextBox></TextBox>
               </StackPanel>
           </HierarchicalDataTemplate>
       </TreeView.Resources>
    </TreeView>
</ListBox>

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

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

发布评论

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

评论(1

各自安好 2024-12-17 16:15:57

您应该使用 ScrollView 属性:

<ListBox ScrollViewer.VerticalScrollBarVisibility="Auto"
         ScrollViewer.CanContentScroll="True">     
    <TreeView>
        <TreeView.Resources>            
            <HierarchicalDataTemplate>                
                <StackPanel>                  
                    <TextBlock/>                    
                    <TextBox></TextBox>                
                </StackPanel>            
            </HierarchicalDataTemplate>        
        </TreeView.Resources>     
    </TreeView> 
</ListBox>

它应该可以工作...

You should be using the ScrollView property:

<ListBox ScrollViewer.VerticalScrollBarVisibility="Auto"
         ScrollViewer.CanContentScroll="True">     
    <TreeView>
        <TreeView.Resources>            
            <HierarchicalDataTemplate>                
                <StackPanel>                  
                    <TextBlock/>                    
                    <TextBox></TextBox>                
                </StackPanel>            
            </HierarchicalDataTemplate>        
        </TreeView.Resources>     
    </TreeView> 
</ListBox>

It Should work...

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