locked
Multi-column ListBox RRS feed

  • Question

  • How can I create a multi-columns ListBox?

    Bear in mind, I don't want a table (ListView, DataGrid, ...) - I want a list box, which gets filled in with items as a vertically oriented WrapPanel: first the first column, then the second, etc.

    I envision something in a way that ItemTemplate for the MultiListBox is a ListBox as well, and the internal ListBox template is a property of MultiListBox. Both the number of items in a single list and the number of shown lists are properties on MultiListBox as well. But how do I actually populate the items into the internal lists? And how do I create those lists?

    Why is WrapPanel as ItemsPanel not enough? I want borders surrounding the internal lists.


    Mikhail

    Friday, July 6, 2012 10:59 AM

Answers

  • Hi MikNik,

    There have been a topic on something that seems to me similar:

    http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/589fb2de-f9e5-4c8b-89db-85d800e96b7b/#4130071d-94e2-4dc6-b736-3ce761b424df

    According to me, the best answer was from Joost Van den Boom who suggested to use the SharedSizeGroup property of ColumnDefinition. Of course, you need to use a Grid as PanelTemplate in this case.

    ... I read again your post...
    I keep my answer but I am not sure it solves your problem...

    In case it doesn't, I think about the UniformGrid that does not do exactly what you are expecting...

    Otherwise, the best solution according to me would be to make a custom arrange of your items, thus create a custom panel (not very complicated) and set it as PanelTemplate of your listbox.

    Hope this helped.

    Regards,


    Charles HETIER http://www.charly-studio.com

    • Marked as answer by MikNik Monday, July 16, 2012 12:21 PM
    Friday, July 6, 2012 12:54 PM

All replies

  • Hi MikNik,

    There have been a topic on something that seems to me similar:

    http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/589fb2de-f9e5-4c8b-89db-85d800e96b7b/#4130071d-94e2-4dc6-b736-3ce761b424df

    According to me, the best answer was from Joost Van den Boom who suggested to use the SharedSizeGroup property of ColumnDefinition. Of course, you need to use a Grid as PanelTemplate in this case.

    ... I read again your post...
    I keep my answer but I am not sure it solves your problem...

    In case it doesn't, I think about the UniformGrid that does not do exactly what you are expecting...

    Otherwise, the best solution according to me would be to make a custom arrange of your items, thus create a custom panel (not very complicated) and set it as PanelTemplate of your listbox.

    Hope this helped.

    Regards,


    Charles HETIER http://www.charly-studio.com

    • Marked as answer by MikNik Monday, July 16, 2012 12:21 PM
    Friday, July 6, 2012 12:54 PM
  • Hi Charles,

    That question was again about creating a table, where every row has related things:

    a1  b1  c1
    a2  b2  c2

    In my case, I want this:

    a1  a5  a9
    a2  a6
    a3  a7
    a4  a8

    The easiest approach is to use a WrapPanel as items panel, but how then I can create borders around groups a1-a4, a5-a8 and a9?

    Then, imagine that if I defined 3 columns to be shown, and there are more items, I want a horizontal scrolling. Is WrapPanel good for this?

    If not - can you hint me on how to write my own Panel in a way that it knows the parameters (properties) of the ListBox?


    Mikhail

    Friday, July 6, 2012 1:08 PM
  • Custom panel is the approach I chose, works for me.

    Mikhail

    Monday, July 16, 2012 12:21 PM