控件模板 - XAML WinRT 按钮填充

Control Template - XAML WinRT Button Padding

我开始使用 XAML 作为我空闲时间的一部分,现在我对标准按钮的填充有疑问。 我有一个位于另一个网格中的网格的以下代码,所以我的页面内有四个网格,问题是按钮被切断,我无法更改按钮的宽度或填充。

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <TextBlock Text="{Binding Name}" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Center" FontSize="24"/>
    <Button x:Name="Player2MinusButton" Content="-" Grid.Row="1" Grid.Column="0" FontSize="20" ></Button>
    <Button x:Name="Player2PlusButton" Content="+" Grid.Row="1" Grid.Column="2" FontSize="20" ></Button>
</Grid>

现在的问题是,正如您在此处的屏幕截图中看到的那样,按钮被切断了:

我已经尝试过设置负数 padding/margin 并制作自定义样式:

<Style TargetType="Button" x:Key="ButtonStyle">
    <Setter Property="Padding" Value="-10,0"/>
</Style>

感谢您的提示,希望我在第一个问题中没有遗漏任何内容。 迈克尔

因为您想要一个比标准按钮更窄的按钮,请设置按钮的最小宽度 属性:

<Button x:Name="Player2PlusButton" Content="+" Grid.Row="1" Grid.Column="2" FontSize="20" MinWidth=50 AutomationProperties.Name="Plus Button" ></Button>

如果您复制按钮模板(右键单击设计器中的按钮,然后 select 编辑模板...并按照提示操作),您会发现以下内容:

<x:Double x:Key="PhoneButtonMinHeight">57.5</x:Double>
<x:Double x:Key="PhoneButtonMinWidth">109</x:Double>

我假设您在 phone 上 运行:Windows 商店按钮模板不同并且没有设置最小值。默认情况下,您的按钮在那里很小。