3

次のように複数の列に sComboBoxを表示したい:ComboBoxItem

誰かが私にこれを行う方法を教えてもらえますか?

私はこれを使用できます:

        <ComboBox.ItemsPanel>
            <ItemsPanelTemplate>
                <UniformGrid Columns="3"/>
            </ItemsPanelTemplate>
        </ComboBox.ItemsPanel>

しかし、列を終了する場所を指定することはできません。

s のプロパティをComboBox使用して、 s を別の列に追加できるようにする方法はありますか?Grid.ColumnComboBoxItemComboBoxItem

4

2 に答える 2

1

ItemsPanelTemplate を WrapPanel に変更します。

<ComboBox>
    <ComboBox.Resources>
        <Style TargetType="ComboBox">
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <WrapPanel IsItemsHost="True" Orientation="Vertical" Width="100" Height="50" />
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="ComboBoxItem">
            <Setter Property="Width" Value="50" />
        </Style>
    </ComboBox.Resources>

    <ComboBoxItem Content="Item 1" />
    <ComboBoxItem Content="Item 2" />
    <ComboBoxItem Content="Item 3" />
    <ComboBoxItem Content="Item 4" />
    <ComboBoxItem Content="Item 5" />
    <ComboBoxItem Content="Item 5" />

</ComboBox>
于 2013-08-13T14:19:28.653 に答える