【问题标题】:Nested ListBox scrolling issue嵌套列表框滚动问题
【发布时间】:2011-11-30 18:24:54
【问题描述】:

我在列表框中有一个列表框,当我尝试降低窗口的高度时,列表框的滚动条不会出现。我想在外部列表框上显示滚动条,因为外部列表框可以有多个内部列表框。 这是我正在使用的 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>

【问题讨论】:

    标签: c# wpf xaml listbox scroll


    【解决方案1】:

    如果我说对了,你不希望内部列表框滚动。

    有两种方法可以实现:

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

    【讨论】:

    • 如果我使用以下网址中提到的样式,它会给我一个编译时错误,因为内容呈现器不支持直接内容
    【解决方案2】:

    将您的内部listbox 更改为ItemsControl,然后滚动条将不会显示在其中。

    【讨论】:

      猜你喜欢
      • 2018-09-14
      • 1970-01-01
      • 2012-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-16
      相关资源
      最近更新 更多