【发布时间】:2011-10-23 13:09:38
【问题描述】:
我有一个相当简单的按钮 ControlTemplate 来设置按钮的样式。 我被要求将按钮的部分文本对齐到按钮的右侧。因此,一些文本将左对齐和右对齐。 对此方法的指针将不胜感激。 这是我目前所拥有的:
<ControlTemplate x:Key="ListItemNameTemplate" TargetType="Button">
<Grid Height="40">
<Border Width="200"
x:Name="BgEnabled"
HorizontalAlignment="Center"
Margin="1,1,1,1"
Background="YellowGreen">
<StackPanel Orientation="Vertical">
<TextBlock Width="150"
x:Name="textBlock"
Text="{TemplateBinding Content}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Foreground="White"
FontSize="24"
FontWeight="Bold"/>
<TextBlock Width="50"
x:Name="textBlock1"
Text="{TemplateBinding Content}"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="White"
FontSize="24"
FontWeight="Bold"/>
</StackPanel>
</Border>
</Grid>
</ControlTemplate>
然而: 一种。第二个文本块不显示。 湾。我需要为第二个文本块指定不同于“内容”的内容。
【问题讨论】:
标签: wpf xaml layout button controltemplate