silverlight - 在 Silverlight 的 ListBox 中使用 WrapPanel

标签 silverlight listbox wrappanel

我有一个 Silverlight 应用程序,它有一个特定宽度的 ListBox。我在我的代码隐藏中动态地向这个 ListBox 添加项目。如果项目需要的空间超过分配的空间,我希望项目换行到下一行并且 ListBox 的高度增加。当它现在运行时,一个水平滚动条出现在我的 ListBox 中。此外,没有包装,因此不会发生增长。我究竟做错了什么?这是我的列表框:

<ListBox x:Name="myListBox" Grid.Column="1" Width="600" MinHeight="24">
  <ListBox.ItemsPanel>
    <ItemsPanelTemplate>
      <controlsToolkit:WrapPanel />
    </ItemsPanelTemplate>
  </ListBox.ItemsPanel>
</ListBox>

感谢您的帮助!

最佳答案

尝试在 ListBox 上将 ScrollViewer.Horizo​​ntalScrollBarVisibility 设置为 Disabled 以防止水平滚动并强制换行。

<ListBox x:Name="myListBox" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.Column="1" Width="600" MinHeight="24">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <controlsToolkit:WrapPanel />
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
</ListBox>

关于silverlight - 在 Silverlight 的 ListBox 中使用 WrapPanel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5185448/

相关文章:

c# - 好的 Silverlight 4.0 图表/图形组件?

wpf - 视觉状态和触发器的差异

c# - 编号列表框

c# - 按钮样式的列表框似乎不起作用

c# - 在 WPF 中指定 WrapPanel 的最大列数

silverlight - HLSL 色调变化算法

c# - 更改 App.RootVisual

c++ - 如何使用目录中的所有文件夹填充 C++ 中的列表框

silverlight - 使用拖放的 Wrap-Panel 记录项目

wpf - MouseDown 在网格中不起作用(仅适用于网格中的按钮)