IF I have two elements in a stackpanel:
<StackPanel Margin="2,2,2,2" Orientation="Horizontal">
<TextBlock Grid.Column="0" Text="{Binding Name}" />
<TextBox Grid.Column="1" Text="{Binding Age}"/>
</StackPanel>
How can I set them with the width equally 50%,50%?
Thanks in advance.
To answer your comment
<Grid>
<!-- Define Columns -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Name}" />
<TextBox Grid.Column="1" Text="{Binding Age}"/>
</Grid>
use UnformGrid with columns 2 or Grid with 2 columns
<UniformGrid Columns="2">
<TextBox></TextBox>
<TextBox></TextBox>
</UniformGrid>
or
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Text="{Binding Name}" />
<TextBox Grid.Column="1"
Text="{Binding Age}" />
</Grid>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With