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
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Navigation Window: Can it be Like a web
• Dynamic Gridview columns Update
• Help me snap to device pixels...
• XMAL browser Application - Error with ru
• PixelFormat: why is the difference?
• how to change ComboBox selection color
• Items.SourceCollection is not flushed wh
• xbap's can't upload images??
• Get all bindings on a page?
• Image-tag with source requiring username
• New Window and STA problem....
• Help: RC1 ListView Memory Leak
• load xaml dynamically in to a parent obj
• Localization question?
• Get an event for SystemParameters changes?

Hot Articles

• ToolBar - OverflowGrid style?
• how do i reinstall component MSACM32.dll
• Add button with dropdown include menu wi
• file IO permission for XBAP
• Event registration fails with No error o
• datbing listview with a generic sortedli
• Using web services with xbap application
• How to access ObjectDataProvider resourc
• Very slow grouping
• Tearing in WPF
• How to get DependencyProperty by its name?
• Canvas.Get...Whatever
• Is it possible to drag objects in a WPF
• Accesskey on ComboBox?
• Not able to get "A Visual" fro

Recommend Articles

• How to Execute a XAML file in Work Flow(
• Where does the teapotModel come from?
• Xbap download gets 404 not found for a DLL
• how to keep doc file in document viewer
• ICollectionView grouping
• how to add text to a 3d shape?
• Listbox ClearSelection
• UserControls XAML
• Tricky: items with ARRAYs as properties:
• How to remove control box from Window?
• Invalid attribute when attempting to bin
• How can i use strings defined in .resx f
• Announcing the WPF/XAML Conversion Tool
• server.mappath equivalent in xaml
• using WPF in MTA applications