views:

59

answers:

1

Hi,

I was just creating a Grid in my XAML when i noticed that Visual Studio automatically creates ColumnDefinitions like this:

<Grid>
   <Grid.ColumnDefinitions>
      <ColumnDefinition></ColumnDefinition>
      <ColumnDefinition></ColumnDefinition>
   </Grid.ColumnDefinitions>
</Grid>

I always stop this from happening by using the shorthand but then wondered would there be any purpose for using the long hand equivalent; can you put anything in between these tags?

Thanks, Kohan.

+1  A: 

Well, you could specify sub-properties using property element syntax, but I have no idea why you would:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition>
            <ColumnDefinition.Width>
                Auto
            </ColumnDefinition.Width>
        </ColumnDefinition>
    </Grid.ColumnDefinitions>

    <TextBlock>Hi</TextBlock>
</Grid>

HTH, Kent

Kent Boogaart