Saturday, April 26, 2008

Content Controls

Ever wonder why the TextBox has a Text property and a Label has a Content property? They both accept text that gets displayed on the window. So why doesn't Label just have a Text property?

TextBox Label
When you see a control that has a Content property that means that you can put another control inside that control. It is somewhat of a container but can only support ONE control. So you could do this:
<Label Height="Auto" VerticalAlignment="Top">
    <StackPanel>
        <Border BorderBrush="Black" CornerRadius="2,2,2,2">
            <TextBlock>Label with text and border</TextBlock>
        </Border>
    </StackPanel>
</Label>
But you can't do this: