If margin is the only difference between the control templates then I suppose you could write an attached property to deal with this say 'AttachedMargin'. On the control give AttachedMargin a value, and use this value inside your Control Template.
Example code:
AttachedMargin Attached property:
using System.Windows;
namespace MarginProject
{
public class AttachedProperties
{
public static Thickness GetAttchedMargin(DependencyObject obj)
{
return (Thickness)obj.GetValue(AttchedMarginProperty);
}
public static void SetAttchedMargin(DependencyObject obj, Thickness value)
{
obj.SetValue(AttchedMarginProperty, value);
}
// Using a DependencyProperty as the backing store for AttchedMargin. This enables animation, styling, binding, etc...
public static readonly DependencyProperty AttchedMarginProperty =
DependencyProperty.RegisterAttached("AttchedMargin", typeof(Thickness), typeof(AttachedProperties), new UIPropertyMetadata(new Thickness(0)));
}
}
XAML:
<Window x:Class="MarginProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:attprops="clr-namespace:MarginProject"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ControlTemplate x:Key="SimpleButton" TargetType="{x:Type Button}">
<Grid>
<Border Name="BackgroundBorder" Background="{TemplateBinding Background}" BorderBrush="Black" BorderThickness="0,0,1,1" CornerRadius="4" />
<Border Name="HighlightBorder" BorderBrush="White" BorderThickness="1,1,0,0" CornerRadius="4" />
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{TemplateBinding Content}" Margin="{Binding Path=(attprops:AttachedProperties.AttchedMargin), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" />
</Grid>
</ControlTemplate>
<Style TargetType="{x:Type Button}">
<Setter Property="Width" Value="100" />
<Setter Property="Height" Value="30" />
<Setter Property="Background" Value="LightBlue" />
<Setter Property="Template" Value="{StaticResource SimpleButton}" />
</Style>
</Window.Resources>
<StackPanel>
<Button Content="Hello WPF!" attprops:AttachedProperties.AttchedMargin="25,0,0,0" />
<Button Content="Hello WPF!" />
</StackPanel>
</Window>