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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WCF and WF
  4. How To Align These Button Groups

How To Align These Button Groups

Scheduled Pinned Locked Moved WCF and WF
questioncsstutorial
3 Posts 3 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.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    I'm trying to create a horizontal row of buttons:

    <StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="0" >

    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.ColumnSpan="2">
        <Button Name="cmdNewFile" VerticalAlignment="Center" Height="30" Width="75" Click="cmdNewFile\_Click">New File...</Button>
        <Button Name="cmdLoad" VerticalAlignment="Center" Height="30" Width="75" Click="cmdLoad\_Click">Load File...</Button>
    </StackPanel>
            
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.ColumnSpan="2" Width="368">
        <Button Name="cmdNewParent" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" >New</Button>
        <Button Name="cmdNewChild" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" >New</Button>
        <Button Name="cmdCopy" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" >Copy</Button>
        <Button Name="cmdRemove" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" >Remove</Button>
        <Button Name="cmdMove" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" >Move</Button>
    </StackPanel>
            
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.ColumnSpan="2">
        <Button Name="cmdSave" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" Click="cmdSave\_Click" >Save</Button>
    </StackPanel>
    

    </StackPanel>

    The first 2 buttons should be to the left, then the middle 5 buttons should be cenetred, then the right 2 buttons should be towards the right. How do I do this?

    Everything makes sense in someone's mind

    M 1 Reply Last reply
    0
    • K Kevin Marois

      I'm trying to create a horizontal row of buttons:

      <StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="0" >

      <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.ColumnSpan="2">
          <Button Name="cmdNewFile" VerticalAlignment="Center" Height="30" Width="75" Click="cmdNewFile\_Click">New File...</Button>
          <Button Name="cmdLoad" VerticalAlignment="Center" Height="30" Width="75" Click="cmdLoad\_Click">Load File...</Button>
      </StackPanel>
              
      <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.ColumnSpan="2" Width="368">
          <Button Name="cmdNewParent" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" >New</Button>
          <Button Name="cmdNewChild" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" >New</Button>
          <Button Name="cmdCopy" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" >Copy</Button>
          <Button Name="cmdRemove" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" >Remove</Button>
          <Button Name="cmdMove" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" >Move</Button>
      </StackPanel>
              
      <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.ColumnSpan="2">
          <Button Name="cmdSave" IsEnabled="False" VerticalAlignment="Center" Height="30" Width="75" Click="cmdSave\_Click" >Save</Button>
      </StackPanel>
      

      </StackPanel>

      The first 2 buttons should be to the left, then the middle 5 buttons should be cenetred, then the right 2 buttons should be towards the right. How do I do this?

      Everything makes sense in someone's mind

      M Offline
      M Offline
      Michael J Eber
      wrote on last edited by
      #2

      Your primary stack panel should be doing this for you. You may need to add some padding in each definition. Using Expression Blend gives you a great visual to ensure they look the way you want them to look.

      J 1 Reply Last reply
      0
      • M Michael J Eber

        Your primary stack panel should be doing this for you. You may need to add some padding in each definition. Using Expression Blend gives you a great visual to ensure they look the way you want them to look.

        J Offline
        J Offline
        Jurgen Rohr
        wrote on last edited by
        #3

        Hi, maybe you should have given us the surrounding container and a hint whereto the buttons should align ... so, I'll make a guess. If you want each whole button-block to be aligned as described in a container of arbitrary (horizontal) size, you must replace the outermost StackPanel with a Grid. The Grid must have three columns with "Auto", "*" and "Auto" as the respective widths. As you already provided the correct alignments, the three remaining StackPanels will be arranged as you wish. BTW what do you intend by giving the "VericalAlignment" of the buttons? Cheers Jürgen

        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