Q:

Using a Button control in a ButtonBase derived template

We have a specific look and feel to buttons in our application and these are defined in a named style for ButtonBase which also happens to be the default style for Button, ToggleButton and RepeatButton.
We also have ToolbarButtons which are derived from ButtonBase and include extra properties such as Text and Icon. These are used to place a specific text and an icon on a ToolbarButton.
The theme for ToolbarButtons is defined as follows in Themes/generic.xaml:
<Style TargetType="{x:Type c:ToolbarButton}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type c:ToolbarButton}">
                <Button Command="{TemplateBinding Property=Command}">
                     .. controls to place text and icon etc ..
                </Button>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

As you can see I'm using a Button control within a control based on ButtonBase and binding the Command to the Command on the contained Button. This hack makes sure that I can override the style of the 'Button' used in the Toolbar by defining the Button default style.
It all seems to work quite well, but it does not feel right using a Button inside a Button. I'm still wondering if I'm doing the right thing. Any ideas?

A:

Your approach is good but you don't have to use a second button in your template, but a ContentPresenter. Use it every time your redefine the template of a ContentControl (a button for example). The BasedOn attribute is useful to override the specific button style.
It looks like this :
<Style TargetType="{x:Type c:ToolbarButton}" BasedOn="{StaticResource {x:Type ButtonBase}}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:ToolbarButton}">

                <StackPanel>

                    <!-- Image -->
                    <Image Source="{TemplateBinding Image}"/>

                    <!-- Content -->
                    <ContentPresenter Content="{TemplateBinding Content}"/>
                </StackPanel>

            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

You will find the same mechanism with the templates of the ItemsControl (ListBox, ListView, etc) with the ItemsPresenter.
UPDATE:
To take your comment in account, maybe you should override a ContentControl to apply your specific chrome to it:

public class ButtonContentControl : ContentControl { }

<Style TargetType="{x:Type local:ButtonContentControl}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:ButtonContentControl}">

                <!-- Specific chrome -->

            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Then you can use it inside the templates of your ButtonBase and your ToolbarButton :
<
Style TargetType="{x:Type ButtonBase}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type c:ToolbarButton}">
                <ButtonContentControl>
                     <!-- ContentPresenter or something else -->
                </ButtonContentControl>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<Style TargetType="{x:Type c:ToolbarButton}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type c:ToolbarButton}">
                <ButtonContentControl>
                     .. controls to place text and icon etc ..
                </ButtonContentControl>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

