Monday, October 10, 2016

SharedSizeGroup in WPF

SharedSizeGroup in WPF

Share same column or row size across multiple grids in wpf.

<Grid Grid.IsSharedSizeScope="True">
   <Grid>
       <Grid.ColumnDefinitions>
           <ColumnDefinition Width="Auto" SharedSizeGroup="Name"/>
           <ColumnDefinition Width="Auto" SharedSizeGroup="Value"/>
       </Grid.ColumnDefinitions>
      <Label Grid.Column=0/>
      <Label Grid.Column=1/>
   </Grid>
   <Grid>
       <Grid.ColumnDefinitions>
           <ColumnDefinition Width="Auto" SharedSizeGroup="Name"/>
           <ColumnDefinition Width="Auto" SharedSizeGroup="Value"/>
       </Grid.ColumnDefinitions>
      <Label Grid.Column=0/>
      <Label Grid.Column=1/>
   </Grid>
</Grid>


The size of columns of both grid is shared each other even that is set through dynamically.

No comments:

Post a Comment