Is it possible to "force" the combobox items in list to appear in say two columns?
For example like this:
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
Full form of C is “COMPILE”.
C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
You can change the ItemsPanel to a WrapPanel, just be careful on the height (you could write a converter to calculate it according to the number of items) :
<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="Value 1" />
<ComboBoxItem Content="Value 2" />
<ComboBoxItem Content="Value 3" />
<ComboBoxItem Content="Value 4" />
<ComboBoxItem Content="Value 5" />
</ComboBox>
Well, you can, here's the XAML:
<ComboBox Name="ComboBox">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="2"/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
Now a simple test, adding numbers from 0 to 8 gives:
Now you can style it all you want... :)
Of course every item (every number, in this particular case) is separate, clickable item, just so there are no misunderstandings.
[EDIT] I have just noticed you want to do it 'the opposite way', that is in 'rows' direction, if so, then maybe it's better to use the WrapPanel
instead, as someone suggested in the other answer. The UniformGrid
fills the grid in the column-wise direction first.
Maybe there's a way to do it with UniformGrid
, but there's no apparent and easy one-click change (I was wrong here before :) )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With