1
我想創建一個模板,我可以反覆使用一個窗體上的按鈕。創建一個按鈕模板
Button
,我希望它包含一個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" />
但可悲的是,這並不工作。有沒有其他的模板,我應該用它來傳遞文本值?