这绝对有可能。首先,你需要自ContentControl派生的类:
public class MyControl : ContentControl ...
然后,你需要类似下面的代码在你的XAML资源文件:
<!-- MyControl -->
<Style TargetType="me:MyControl">
<Setter Property="Foreground" Value="Black" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="BorderMargin" Value="4,4,4,0" />
<Setter Property="FooterMargin" Value="4,0,4,4" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="me:MyControl">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Content -->
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<!-- Footer Buttons -->
<Grid x:Name="grdFooter" Grid.Row="1" Background="{StaticResource Footer_Bkg}" Margin="{TemplateBinding FooterMargin}">
<!--Buttons here-->
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
最后使用它在一个页面,你只需要像这样:
<me:MyControl x:Name="MainPage">
<Grid x:Name="LayoutRoot">
<!--Cool stuff here-->
</Grid>
</me:MyControl>