Set two children with the same width, each with 50% in wpf

IF I have two items on the stack:

<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 a width equal to 50%, 50%?

Thanks in advance.

+6
source share
2 answers

To respond to 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> 
+18
source

use UnformGrid with 2 columns or 2-column grid

 <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> 
+12
source

Source: https://habr.com/ru/post/913496/


All Articles