Budda
Budda

Reputation: 18353

SilverLight: how to align buttons in stackpanel center and right

In the bottom "row" (inside of StackPanel with Horizontal orientation?) of my SilverLight control I would like to display two things:

  1. "Save" button - to center-aligned
  2. Text field with small text (kind of Version) - to be aligned to the right

How to do that? If I put both inside of stackpanel their alignement will be the same... Wrap panel just tie them together...

Please advise.

Thank you.

Upvotes: 0

Views: 2197

Answers (1)

Stainedart
Stainedart

Reputation: 1979

Within your stack panel create a grid with 2 columns then align each column independantly.

<StackPanel x:Name="Layout" Background="Black">
    <Grid>
       <Grid.ColumnDefinitions>
           <ColumnDefinition Width="2*"></ColumnDefinition>
           <ColumnDefinition Width="2*"></ColumnDefinition>
       </Grid.ColumnDefinitions>
        <Label Name="Left" HorizontalAlignment="Left" grid.column=1/>
        <Button x:Name="Button2" Content="And me!" HorizontalAlignment="Center" ></Button>
    </Grid>
</StackPanel>

No the perfect syntax but its just to demonstrate the idea.

Hope this helps!

Upvotes: 2

Related Questions