c# - 嵌套列表框滚动问题

标签 c# wpf xaml listbox scroll

我在列表框中有一个列表框,当我尝试降低窗口的高度时,列表框的滚动条没有出现。我想在外部列表框上显示滚动条,因为外部列表框可以有多个内部列表框。 这是我正在使用的 XAML。谁能告诉我问题出在哪里?

<ListBox Name="MasterListBox" HorizontalAlignment="Stretch" Width="200">
    <ListBoxItem >
        <ListBox Name="Child1" BorderBrush="{x:Null}">
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
            <ListBoxItem Content="testing item1" />
            <ListBoxItem Content="testing item2" />
            <ListBoxItem Content="testing item3" />
        </ListBox>
    </ListBoxItem>

</ListBox>

最佳答案

如果我没猜错,您不希望内部列表框滚动。

有两种方法可以实现:

1) 将内部列表框更改为 ItemsPanel。 2) 如果您确实需要将内部控件保留为 ListBox,则必须在内部 Listbox 控件的模板中将 ScrollViewer 替换为 ContentPresenter。请参阅此链接(它被标记为正确答案)> http://forums.silverlight.net/t/193872.aspx/1

关于c# - 嵌套列表框滚动问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8330932/

相关文章:

c# - 清除图形对象为黑色或其他 RGB

c# - 十进制值 1,5 在 DB 中最终为 15 - 如何,为什么?

c# - 在 C# 和 WPF 中选择屏幕截图不准确

c# - WPF 中 DataGrid 的双向绑定(bind)

Windows Universal App(十)隐藏栏

c# - Mysql规范化?或者其他方式?

c# - ArgumentException - 在异步中对事件 TaskScheduled 使用未定义的关键字值 1

c# - 将嵌套列表绑定(bind)到 WPF Canvas 面板

wpf - 有免费的 WPF 主题吗?

c# - DateTimePicker 日历默认为上次选择的月份/年份