2016-07-15 7 views
0

コンボボックスに30個のアイテムがあります。私はコンボボックスに列と行を追加する方法を探しています。ここで
私が何をしたいです:コンボボックスのグリッドの列と行

enter image description here

コンボボックス4列、7行(行= ITEMCOUNT個/列)を持っています。
Itemクラス:

public class ItemSymbol{ 
    public string ImageName{ 
    get; set; 
    } 

    public string Comment{ 
    get; set; 
    } 
} 

のViewModel:

List<ItemSymbol> lstsymbol=new List<ItemSymbol>(30){ 
    new ItemSymbol(){[email protected]"Resources\bunny.png",Comment="funny"}, 
    new ItemSymbol(){[email protected]"Resources\hand.png",Comment="communication"}, 
    new ItemSymbol(){[email protected]"Resources\heart1.png",Comment="love"}, 
    new ItemSymbol(){[email protected]"Resources\heart2.png",Comment="love"} 
}; 

Window1.xaml:

<ComboBox x:Name="cbo" 
ItemsSource="{Binding lstsymbol}" 
SelectedItem="{Binding SelectedItem}"> 
<ComboBox.ItemTemplate> 
    <DataTemplate> 
    <StackPanel Orientation="Vertical"> 
    <Image Width="30" Height="30" 
     Source="{Binding ImageRes}" Margin="5" ToolTip="{Binding Comment}"/> 
    </StackPanel> 
    </DataTemplate> 
</ComboBox.ItemTemplate> 
</ComboBox> 

答えて

1

XAMLでのコンボボックスに、この要素を追加します。

<ComboBox.ItemsPanel> 
    <ItemsPanelTemplate> 
     <UniformGrid Rows="7" Columns="4" /> 
    </ItemsPanelTemplate> 
</ComboBox.ItemsPanel> 
は(しかし、あなたは7x4が少ないし、30であることを知っていますか?)

+0

:-)はい、私はthat.thankを知っている!それはそれでコンテンツに合わせて均一の幅、高さを調整することworking.Howです@Fratyx – Jandy

+0

UnformGridの画面サイズ、または行と列の数を意味しますか? – Fratyx

+0

私は質問を更新しました.Flashyx – Jandy

関連する問題