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. Stretch StatusBarItem

Stretch StatusBarItem

Scheduled Pinned Locked Moved WPF
question
3 Posts 2 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.
  • J Offline
    J Offline
    Jean Louis Leroy
    wrote on last edited by
    #1

    I'm trying to make a StatusBar with four text items distributed evenly across the available width like this:

    -----------------------------------------------------------------
    | status1 | status2 | status3 | status4 |

    Instead I'm getting this:

    -----------------------------------------------------------------
    | status1 | status2 | status3 | status4 |

    ...when I use the following code, which looks like it should do the trick:

    What's wrong ? Thanks, J-L

    I 1 Reply Last reply
    0
    • J Jean Louis Leroy

      I'm trying to make a StatusBar with four text items distributed evenly across the available width like this:

      -----------------------------------------------------------------
      | status1 | status2 | status3 | status4 |

      Instead I'm getting this:

      -----------------------------------------------------------------
      | status1 | status2 | status3 | status4 |

      ...when I use the following code, which looks like it should do the trick:

      What's wrong ? Thanks, J-L

      I Offline
      I Offline
      Ian Shlasko
      wrote on last edited by
      #2

      I believe the StatusBar, by default, uses a DockPanel to handle its layout... Unless you specify otherwise, a DockPanel will left-dock all but the last item (Which will fill the remaining space). You can change the layout by changing the ItemsPanel property of the StatusBar (It's just an ItemsControl):

      <StatusBar ...>
      <StatusBar.ItemsPanel>
      <ItemsPanelTemplate>
      ...
      </ItemsPanelTemplate>
      </StatusBar.ItemsPanel>

      ...items...

      </StatusBar>

      If the separators aren't necessary, the easiest way is to use a UniformGrid, which will divide the space equally (Just set Rows = 1 and leave Columns blank). If you want to keep the separators, you could try using a regular Grid, and define columns for everything ("Auto" for separator columns, "*" for item columns).

      Proud to have finally moved to the A-Ark. Which one are you in?
      Author of the Guardians Saga (Sci-Fi/Fantasy novels)

      J 1 Reply Last reply
      0
      • I Ian Shlasko

        I believe the StatusBar, by default, uses a DockPanel to handle its layout... Unless you specify otherwise, a DockPanel will left-dock all but the last item (Which will fill the remaining space). You can change the layout by changing the ItemsPanel property of the StatusBar (It's just an ItemsControl):

        <StatusBar ...>
        <StatusBar.ItemsPanel>
        <ItemsPanelTemplate>
        ...
        </ItemsPanelTemplate>
        </StatusBar.ItemsPanel>

        ...items...

        </StatusBar>

        If the separators aren't necessary, the easiest way is to use a UniformGrid, which will divide the space equally (Just set Rows = 1 and leave Columns blank). If you want to keep the separators, you could try using a regular Grid, and define columns for everything ("Auto" for separator columns, "*" for item columns).

        Proud to have finally moved to the A-Ark. Which one are you in?
        Author of the Guardians Saga (Sci-Fi/Fantasy novels)

        J Offline
        J Offline
        Jean Louis Leroy
        wrote on last edited by
        #3

        It works perfectly, thanks a lot !

        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