0
このテンプレートボタンではテキストを表示できません。
このボタンに表示するにはコンテンツ値が必要です。テンプレートボタンのテキスト
<ControlTemplate x:Key="BooksButton" TargetType="{x:Type Button}">
<Grid Margin="0,9,0,0">
<Rectangle
x:Name="rctBooks"
Width="97"
Height="40"
Margin="-2,0,-1,-4"
HorizontalAlignment="Left"
VerticalAlignment="Top"
RadiusX="10"
RadiusY="10"
Stroke="AliceBlue"
StrokeThickness="2">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Offset="0" Color="Black" />
<GradientStop Color="#FFCBC6A9" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</ControlTemplate>
<Button
x:Name="btnMarkTwainStories"
Width="96"
Height="50"
Margin="10,0,0,0"
HorizontalAlignment="Left"
Click="btnMarkTwainStories_Click"
Content="Mark Twain"
FontFamily="Times"
FontSize="24"
Foreground="Black"
Template="{DynamicResource BooksButton}"
>
ControlTemplateには、Contentプロパティの値/オブジェクトを取得してレンダリングする要素はありません。コンテンツの価値を見ることができないという驚きはありません(おそらく、コントロールテンプレートがどのように機能するかを知るために、ボタンの標準コントロールテンプレートを見るのは良い考えです...) – elgonzo
あなたの手を得る方法標準コントロールテンプレート(ボタンだけではありません):http://stackoverflow.com/a/28212036/2819245または、StyleSnooperのようなツールを使用してください:https://github.com/drewnoakes/style-snooper – elgonzo
@elgonzo私に正しい方向を教えていただきありがとうございます。 StyleSnooperは興味があるようです.... – LetzerWille