Please pardon me for being a complete newbie, but I’m following a tutorial (Creating a Custom WPF Button Template in XAML), and I’m running into the error:
FormatException was thrown due to document error: Property ‘Template’ was not found in type ‘FrameworkElement’.
It seems that the error stems from the following code in XAML:
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="border"
BorderThickness="1"
Padding="4,2"
BorderBrush="DarkGray"
CornerRadius="3"
Background="{TemplateBinding Background}">
<Grid >
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center" Name="contentShadow"
Style="{StaticResource ShadowStyle}">
<ContentPresenter.RenderTransform>
<TranslateTransform X="1.0" Y="1.0" />
</ContentPresenter.RenderTransform>
</ContentPresenter>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center" Name="content"/>
</Grid>
</Border>
I’ve been looking all over for a solution, but haven’t found one…this leads me to believe that I’m either overlooking or overthinking something.
What am I missing? Thank you in advance for any help!
A
FrameworkElementdoesn’t have aTemplateproperty. The Template is usually defined on aControlclass. This is because most WPF elements derive fromFrameworkElementbut they don’t all have a Template (StackPanel, for example). Your Setter is probably within a Style (you didn’t post that part). Make sure theTargetTypeof theStyleis the correct type (most likely Button).