|
index > Windows Presentation Foundation ("Avalon") > How to put 2 ListBoxItem on same row? |
|
How to put 2 ListBoxItem on same row? |
|
|
Since everything is possible in WPF (well almost) this should be a pieece of cake.
when you have a number of ListBoxItems in a ListBox, they´re listed one item per row.
But what if my ListBox.Width = 300 and my ListBoxItem.Width = 100 then
there´s some waste of space. Before I dig in to it I just want to know
if the way to do it (if doable) is by overriding some
methods that´s placing the itmes out so I can manually place them out,
animate them etc..
Well, why don´t I use like a Stackpanel ? I need to use a control that
inherits from ItemsControl so I can use ItemsSource to databind my
object in xaml.
Would be grateful for some hints in the right direction
Have a nice day
/erik
| | Erik BN | ...and by ovveriding the layout of my Items, will that affect any user interacting? Like the keyUp, keyDown etc...
/e
| | Erik BN | try something like this
< ListBox Name="item1">
< ListBox.ItemsPanel>
< ItemsPanelTemplate>
< UniformGrid IsItemsHost="True" Columns="3"></UniformGrid>
</ ItemsPanelTemplate>
</ ListBox.ItemsPanel>
</ ListBox> | | lee d | ok, totally missed the ItemsPanel but the name explains it all!
thanks for the help
| | Erik BN | You'd probably want to use a FlowLayoutPanel to do what you want. It's child elements can be any size and it will automatically adjust the layout as the panel resizes. There are even some examples out there to add a little flourish to the layout process.
What's in your toolbelt? http://www.codeplex.com/Wiki/View.aspx?ProjectName=wpftoolbelt | | ivolved_Mike_Brown |
|
|
| reply 5 |
|
|
|
You can use google to search for other answers |
|
|
|
|
More Articles |
|
| Textblock animation in RC1 |
| BitmapFrame to stream conversion |
| Databinding dropped in composite control with DP |
| Graphical Design Tools for WPF? |
| How can i define string tables in WPF project |
| Event registration fails with No error or Exception - Bad Bug |
| Item Selection Area |
| Where is WPF Version of SendKeys? |
| Unit testing WPF controls with NUnit |
| ListBox item scroll animation |
|