I am working on a WPF application that uses the Telerik RAD controls for WPF. The application will be used on a PC with a touch screen, so I need to make things like pickers on the DateTimePicker control larger so they can be easily pressed by people with sausage fingers like my own.
I originally used Expression Blend to edit a copy of the control's template. That created a ControlTemplate in the UserControl's XAML file that I was designing. I have another UserControl I'm working on now that will also use the DateTimePicker, so I want to reuse the ControlTemplate.
What I did was I moved the modified template into a new named Style in the project's (a WPF Control Library) Generic.XAML. Here's a short snippet of the Generic.xaml:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:CarSystem.CustomControls" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:Telerik_Windows_Controls_Chromes="clr-namespace:Telerik.Windows.Controls.Chromes;assembly=Telerik.Windows.Controls"> <Style x:Key="RadDateTimePickerControlTemplate1" TargetType="{x:Type telerik:RadDateTimePicker}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type telerik:RadDateTimePicker}"> . . . </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary> Here's a snippet of the XAML where I reference the style:
<UserControl x:Class="CarSystem.CustomControls.ReportCriteria" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:cs="clr-namespace:CarSystem.CustomControls" mc:Ignorable="d" Height="648" Width="1117"> <Grid Background="{DynamicResource ContentBackground}"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <GroupBox BorderBrush="Black" FontSize="20" FontWeight="Bold" Grid.Row="0" Header="Report Criteria: " Margin="5"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="320" /> <ColumnDefinition Width="200" /> <ColumnDefinition Width="450" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="110" /> </Grid.ColumnDefinitions> <GroupBox BorderBrush="Black" FontSize="20" FontWeight="Bold" Grid.Column="0" Header="Date Range:" Margin="5"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="1*" /> <ColumnDefinition Width="2*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <TextBlock FontSize="18" FontWeight="Bold" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" Text="Start Date: " /> <telerik:RadDateTimePicker FontSize="18" FontWeight="Bold" Grid.Column="1" Grid.Row="0" Name="StartDatePicker" Style="{DynamicResource RadDateTimePickerControlTemplate1}" /> <TextBlock FontSize="18" FontWeight="Bold" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" Text="End Date: " /> <telerik:RadDateTimePicker FontSize="18" FontWeight="Bold" Grid.Column="1" Grid.Row="1" Name="EndDatePicker" Style="{DynamicResource RadDateTimePickerControlTemplate1}" /> </Grid> </GroupBox> . . . </GroupBox> </Grid> </UserControl> When I work in Expression Blend, everything looks fine. I see the change in the width of the drop down button for the control. Back in Visual Studio, everything compiles fine, but the change does not show up -- I see the default style for the control only, and the references to the style have a blue squiggly line under them. When you hover the mouse over the squiggly line, the following message is displayed:
The resource "RadDateTimePickerControlTemplate1" cannot be resolved. The same thing happens if I change "DynamicResource" to "StaticResource" in the XAML. Also, I have made no changes to the Assembly.Info file for the project.
How do I fix this?
Thanks
Tony