Kreshnik
Kreshnik

Reputation: 2831

How can I float the elements inside a tag to the left or right, like we do in html?

I'm using the WPF Grid Control, for the layout.. and inside row 2, col 2 I want to put two buttons inside that cell, but without using positioning attributes..

<Button Content="Confirm" MinWidth="80" Margin="3" Grid.Row="2" Grid.Column="2" HorizontalAlignment="Right" />
<Button Content="Cancel" MinWidth="80" Margin="3" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="2" />

In this example, both buttons are positioned one over the other.

Upvotes: 1

Views: 912

Answers (1)

w.b
w.b

Reputation: 11228

Place them inside StackPanel:

<StackPanel Grid.Row="2" Grid.Column="2" Orientation="Horizontal">
    <Button Content="Confirm" MinWidth="80" Margin="3" />
    <Button Content="Cancel" MinWidth="80" Margin="3" />
</StackPanel>

Upvotes: 3

Related Questions