Saturday, April 21, 2007

Some Beginning XAML

XMAL gives developers the means to customize their user interfaces in ways that have not been available using traditional tools (i.e. Windows Forms).

The following XMAL snippet gives a simple example:

<StackPanel Background="Beige">

<Button>

<Button.ToolTip>
<TextBlock FontWeight="UltraBold" TextAlignment="Center">
<Ellipse Width="20" Height="20" Stroke="Blue" Fill="AliceBlue"></Ellipse>
<Label>A ToolTip Message</Label>
<Rectangle Height="20" Width="20" Fill="AliceBlue" Stroke="Blue" StrokeThickness="2" ></Rectangle>
</TextBlock>
</Button.ToolTip>

<Button.Content>
<TextBlock FontWeight="UltraBold" TextAlignment="Center">
<Ellipse Width="20" Height="20" Stroke="Red" Fill="Pink"></Ellipse>
<Label>Press Me</Label>
<Rectangle Height="20" Width="20" Fill="Pink" Stroke="Red" StrokeThickness="2" ></Rectangle>
</TextBlock>
</Button.Content>

</Button>
</StackPanel>

The button defines its own content and a tooltip. Notice that the content and tool tip defintions can contain other XAML, allowing for very interesting presentation. Here, both the button and tool tip have tradtional text (i.e. Press Me) as well as a Rectangle and Ellipse. No longer are developers constrained by text only or creating their own images with hope that a control supports display of an image.

The other good news is that when the window with the above is resized, the button contents are automatically adjusted to ensure that it continues to have a consistent look and feel -- and the best part, a developer does not have to do anything to get this behavior!!

0 Comments:

Post a Comment

<< Home