I have a base style, say:
<Style x:Key="DefaultButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Background" Value="{StaticResource DefaultButtonBackground}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid x:Name="ButtonShapeGrid" Height="{TemplateBinding Height}" Width="{TemplateBinding Height}">
<!-- snip some shaping Xaml. -->
<ContentPresenter
Grid.RowSpan="2"
VerticalAlignment="{TemplateBinding VerticalAlignment}" HorizontalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Now, I have a need to create some styles that replace the content of the button with something fixed...like so (where CloseButtonGlyph is a path resource). This works fine:
<Style x:Key="CloseButtonStyle" BasedOn="{StaticResource DefaultButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="Content" Value="{StaticResource CloseButtonGlyph}" />
</Style>
However, I also need to add arbitrary Xaml into the content, and this is where I have a problem. The following doesn't work (I get a design-time error stating that the content can't be derived from ContentElement or Visual) when the style is used in a WPF window or control:
<Style x:Key="WingDingStyle" BasedOn="{StaticResource DefaultButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="Content">
<Setter.Value>
<TextBlock FontFamily="WebDings" Text="3" FontSize="18" Foreground="White" />
</Setter.Value>
</Setter>
</Style>
I'm at a loss as what I need to do. Putting a TextBox in the content of a button in a window or control works fine, why not in a style?