【发布时间】:2012-12-05 14:08:26
【问题描述】:
我有多个使用类似结构的 UserControl XAML 文件。我想删除这种重复并考虑使用覆盖 UserControl 模板的样式(然后将 ContentPresenter 用于自定义部分)。
但显然不能覆盖 UserControl 的模板。
我怎样才能做到这种干净的方式?派生自其他东西,然后是 UserControl?
<UserControl x:Class="Class1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<sdk:Label Grid.Row="0" Content="Title1" Style="{StaticResource Header1}" />
<Border Grid.Row="1">
...
</UserControl>
<UserControl x:Class="Class2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<sdk:Label Grid.Row="0" Content="Title2" Style="{StaticResource Header1}" />
<Border Grid.Row="1">
...
</UserControl>
【问题讨论】:
标签: silverlight xaml user-controls