您好如何制作此按钮:
<Button x:Name="StartButton" Background="Transparent" Click="StartButton_Click">
<Button.Content>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock FontSize="18" FontFamily="Segoe MDL2 Assets" Text=" " VerticalAlignment="Center"/>
<TextBlock FontSize="18" Text="Start"/>
</StackPanel>
</Button.Content>
</Button>
填充其父级(水平)并将其内容对齐?
答案 0 :(得分:1)
这就是答案:
<Button x:Name="StartButton" Background="Transparent" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left">
<TextBlock FontSize="18">
<Run FontFamily="Segoe MDL2 Assets" Text=" "/>
<Run Text="Start"/>
</TextBlock>
</Button>
答案 1 :(得分:0)
为了获得预期的结果,我建议您使用<Run>
来定义TextBlock
这应该是:
<Button x:Name="StartButton" Background="Transparent" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Click="StartButton_Click">
<TextBlock FontSize="18" HorizontalAlignment="Left">
<Run FontFamily="Segoe MDL2 Assets" Text=" "/>
<Run Text="Start"/>
</TextBlock>
</Button>