It's an interesting thing that you cannot edit the DatePicker
template. I found out by looking at the source code that for some reason it occurs because the template is defined in the main control theme - Generic.xaml
and it has no BorderBrush
property defined per se.
Download the package - you will need it to build a custom control on top of the existing skeleton.
You should open that theme file and if yo look at the template for DatePicker
, you can edit the values for BorderBrush
and BorderThickness
. One thing to remember - once you re-compile the source, you need to make sure that you are using the correct library (when referencing in the main project). By default, when you add a Microsoft.Phone.Controls.Toolkit unit, it will reference the library registered in GAC (assuming that you installed the toolkit) and take the one that is located in the SDK folder - you don't want that. Either change the library name or change the local copy.
If you need a tutorial for this, I just wrote one.
Here is the modified style (modified in the source code for easier reuse):
<Style TargetType="controls:DatePicker">
<Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Azure"/>
<Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="PickerPageUri" Value="/Microsoft.Phone.Controls.Toolkit;component/DateTimePickers/DatePickerPage.xaml"/>
<Setter Property="ValueStringFormat" Value="{}{0:d}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:DatePicker">
<StackPanel>
<ContentControl
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
Foreground="{StaticResource PhoneSubtleBrush}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="12,0,12,-4"/>
<Button
x:Name="DateTimeButton"
Content="{TemplateBinding ValueString}"
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
FontFamily="{TemplateBinding FontFamily}"
Foreground="{TemplateBinding Foreground}"
Height="72"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>