Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. How to make listbox list items in horizontal

How to make listbox list items in horizontal

Scheduled Pinned Locked Moved WPF
tutorialquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Loveisasea
    wrote on last edited by
    #1

    By default listbox list items in vertical. Now I want to list them in horizontal. I remember this can only be set in ListBox's Style. But I forget the full name of the Property and can not find it out in the past 2 hours. :(( Anyone know this property name?

    A M 2 Replies Last reply
    0
    • L Loveisasea

      By default listbox list items in vertical. Now I want to list them in horizontal. I remember this can only be set in ListBox's Style. But I forget the full name of the Property and can not find it out in the past 2 hours. :(( Anyone know this property name?

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      Put the ItemsPresenter inside a Stackpanel with horizontal orientation.

      M 1 Reply Last reply
      0
      • A Abhinav S

        Put the ItemsPresenter inside a Stackpanel with horizontal orientation.

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Is that better (or different) to using a contentpresenter, and I used a wrappanel as there were quite a few images.

        Never underestimate the power of human stupidity RAH

        A 1 Reply Last reply
        0
        • M Mycroft Holmes

          Is that better (or different) to using a contentpresenter, and I used a wrappanel as there were quite a few images.

          Never underestimate the power of human stupidity RAH

          A Offline
          A Offline
          Abhinav S
          wrote on last edited by
          #4

          If a VirtualizingStackPanel has been used, I suppose there might be a performance benefit in terms of loading a large amount of data together (inside an ItemsControl). A ListBox uses this panel by default. Otherwise I'm not aware of any differences.

          L 1 Reply Last reply
          0
          • A Abhinav S

            If a VirtualizingStackPanel has been used, I suppose there might be a performance benefit in terms of loading a large amount of data together (inside an ItemsControl). A ListBox uses this panel by default. Otherwise I'm not aware of any differences.

            L Offline
            L Offline
            Loveisasea
            wrote on last edited by
            #5

            Thanks guys. My design intention is listbox inside listbox. The items of the outer listbox binds with days. so it is better let days shown horizontal. Items of inner listbox binds with things to do in specific day. So If only a property setting can achieve it, it will save time and maintainace effort.

            1 Reply Last reply
            0
            • L Loveisasea

              By default listbox list items in vertical. Now I want to list them in horizontal. I remember this can only be set in ListBox's Style. But I forget the full name of the Property and can not find it out in the past 2 hours. :(( Anyone know this property name?

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              Maybe this?

              <ListBox >
              <ListBox.ItemsPanel>
              <ItemsPanelTemplate>
              <VirtualizingStackPanel Orientation="Horizontal" IsItemsHost="True" />
              </ItemsPanelTemplate>
              </ListBox.ItemsPanel>
              </ListBox>

              Mark Salsbery :java:

              S 1 Reply Last reply
              0
              • M Mark Salsbery

                Maybe this?

                <ListBox >
                <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                <VirtualizingStackPanel Orientation="Horizontal" IsItemsHost="True" />
                </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                </ListBox>

                Mark Salsbery :java:

                S Offline
                S Offline
                SledgeHammer01
                wrote on last edited by
                #7

                Mark has given you the "correct" answer here. All you need to do is override the ItemsPanelTemplate. There is no need to re-invent the wheel as other posters have suggested.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups