代码之家  ›  专栏  ›  技术社区  ›  Jeaf Gilbert

在水平堆叠面板中下移溢出内容

  •  0
  • Jeaf Gilbert  · 技术社区  · 14 年前

    我在扩展器中有一个列表框:

    <ListBox ItemsSource="{Binding MySource">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <RadioButton Content="{Binding MyContent}" />
            </DataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>
    

    我把单选按钮包装成水平方向。我希望溢出单选按钮向下移动,如右图所示(没有水平滚动条)。现在,我的和左边的一样。

    Stackpanel Orientation="Horizontal" http://www.empirepic.com/images/i8f5sevyzqch10uodso.jpg

    1 回复  |  直到 14 年前
        1
  •  2
  •   Josh    14 年前

    你需要用包装纸,而不是堆垛板。在WPF中,它内置在主程序集中,但在Silverlight中,您需要获得 Silverlight Toolkit

    <ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding MySource">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <RadioButton Content="{Binding MyContent}" />
            </DataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <t:WrapPanel />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>