21.2.09

WPF Toolkit and the DatePicker Control

The journey started out with a hunt for a date control that would form part of the user interface. The core WPF API does not come equipped with this capability so I decided rather than lose precious time trying to build one, I would Google for it.

A download from CodePlex later, I had the binaries  on the development machine and I was ready to rock. Lo and behold…there was none of the precious documentation that us developers have become fat on, but as I soon discovered integrating the control is pretty simple.

I added the new assembly reference to VS2008 and this was loaded as shown below:

image

The XAML for the integrated control is

<GroupBox Grid.Row="5" Header="Call back notes" FontSize="14" Margin="1,1,1,308" Visibility="Hidden" Name="CallBackNotesGroup">
<
StackPanel Grid.Row="5" Height="218" VerticalAlignment="Top">
<
TextBox Margin="2,2,2,2" Name="textBox1" TextWrapping="Wrap" MaxWidth="300" MaxHeight="120" BorderBrush="Black" Height="100" />
<
Controls:DatePicker>
</
Controls:DatePicker
>
<
Button Grid.Row="3" Margin="2,2,2,2" Name="button1" FontSize="14" Width="163" HorizontalAlignment="Left">Arrange call back</Button>
</
StackPanel>
</
GroupBox>


The rendered UI looks something like this:



image 



The control exhibits automatic polite validation behaviour which is activated when an invalid date string is entered in the text box. That’s one layer of validation that I don’t need to worry about!

No comments: