我试图为一个按钮创建一个模板, 我可以在窗体上一次又一次地使用这个按钮。
按钮
, 我要它包含一个 Grid
, 底行内有两个行和自定义的文本块 。
这是我到现在为止得到的, 但我不认为这是对的, 因为我想从按钮元素中设置文本。
<ControlTemplate TargetType="Control">
<Grid Width="444">
<Grid.RowDefinitions>
<RowDefinition Height="51" />
<RowDefinition Height="36" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="#286c97"></Grid>
<Grid Grid.Row="1" Background="#5898c0">
<TextBlock Grid.Row="1" FontFamily="Segoe UI" FontSize="12" Text="{TemplateBinding Content}" />
</Grid>
</Grid>
</ControlTemplate>
然后打电话给模板 我希望我可以去:
<Button Content="This is the text" />
但不幸的是,这不起作用。我是否还要用其他模板来传递文本价值?