I was just creating a Grid in my XAML when i noticed that Visual Studio a开发者_StackOverflowutomatically 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.
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>
Maybe if you wanted to use an attached property:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition>
<mystuff:Adorners.Overlay>
<TextBlock>I'm on top of the column!</TextBlock>
<mystuff:Adorners.Overlay>
</ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock>Hi</TextBlock>
</Grid>
I haven't actually tried this it seems like it should work if you co a use case for it.
精彩评论