Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit RC0 - Style x:Key="xx" TargetType="DatePicker" causes runtime "XamlParseException: Invalid attribute value DatePicker"
2 replies. Latest Post by MyScreenNameWasTaken on December 5, 2008.
(0)
dbaechtel
Member
59 points
207 Posts
09-26-2008 5:57 PM |
I have a recent MSDN Magazine sample SL 2.0 application code and it defines a style for a DatePicker control starting with the line: Style x:Key="xx" TargetType="DatePicker" It compiles OK but generates a runtime error: "Invalid attribute value DatePicker for property TargetType." DatePicker is defined in the Object Browser as a member of System.Windows.Controls. Why is it Invalid to define a Style for a DatePicker in SL 2 RC0 ? How do I use and define a style for a DatePicker control in SL 2 RC0 ?
Bill Reiss
Contributor
4840 points
919 Posts
09-26-2008 6:10 PM |
I think you'll need to declare the namespace in the XAML:
Then refer to it as TargetType="controls:DatePicker"
the namespace "controls" can be whatever you want as long as they match.
MyScreen...
18 points
16 Posts
12-05-2008 11:26 AM |
Possibly exhibiting a bug which is mentioned in the readme.txt
If the template is defined in the app.xaml (like <Application.Resources>) then move it into page.xaml under something like <UserControl.Resources> for the entire page.
In my case, you could see it was a phoney error because the VS IDE reported the error as occurring in page.xaml when it wasn't in that page at all.
Luke