Home > Net >  WPF xaml UniformGrid Placing Third Control on a separate line
WPF xaml UniformGrid Placing Third Control on a separate line

Time:09-13

I need help with using UniformGrid when I place a third button it goes to the next Line.

<UniformGrid Grid.Row="2" HorizontalAlignment="Right">
    <Button  x:Name="RuntimeButton" Style="{StaticResource BigButton}" Command="{Binding SelectRuntimeCommand}">Runtime</Button>
    <Button  x:Name="ConfigButton" Style="{StaticResource BigButton}" Command="{Binding SelectConfigureCommand}">Configure</Button>
    <Button  x:Name="LogButton" Style="{StaticResource BigButton}">Log</Button>
</UniformGrid>

CodePudding user response:

UniformGrid seems to have Columns=2 internally so if you want three items to the right you have to set Columns=3

<UniformGrid Grid.Row="2" Columns="3" HorizontalAlignment="Right">

CodePudding user response:

set Rows="1" to explicitly say that you need a single line and number of Columns will be equal to the count of child elements (this way you are guarding against future changes, e.g. adding/removing/hiding button)

<UniformGrid Grid.Row="2" Rows="1" HorizontalAlignment="Right">
    <Button  x:Name="RuntimeButton" Style="{StaticResource BigButton}" Command="{Binding SelectRuntimeCommand}">Runtime</Button>
    <Button  x:Name="ConfigButton" Style="{StaticResource BigButton}" Command="{Binding SelectConfigureCommand}">Configure</Button>
    <Button  x:Name="LogButton" Style="{StaticResource BigButton}">Log</Button>
</UniformGrid>
  • Related