2010-10-18 31 views

回答

7

你有沒有嘗試Rectangle的保證金設置爲0

<Button x:Name="Button" BorderThickness="0" Margin="0" Padding="0" Width="96" Height="96"> 
    <Rectangle Fill="Blue" Margin="0" Width="96" Height="96" /> 
</Button> 

編輯:墊料必須來自按鈕控件模板。嘗試使用自定義模板:

<Style x:Key="MyButton" TargetType="Button"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="Button"> 
       <Grid> 
        <Rectangle Fill="Blue" Margin="0" Width="96" Height="96" /> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

<Button x:Name="Button" BorderThickness="0" Margin="0" Padding="0" 
    Width="96" Height="96" Style="{StaticResource MyButton}" /> 
+0

沒錯。那也行不通。 – 2010-10-18 05:53:41

0

我不能產生明顯的行爲,但我不知道,你會不會在Windows Phone應用程序進行開發?

如果是你最有可能看到的是不是Padding的結果,但「PhoneTouchTargetOverhang」的結果。這是在App.xaml中找到的Thickness資源,「按鈕外部邊框Margin」的「PhoneButtonBase」樣式使用該資源。

這實際上是一個副本的Windows Phone 7應用於按鈕的默認樣式。要更換它,你將需要實際指定的按鈕,使用「PhoneButtonBase」的風格,那麼更改「PhoneTouchTargetOverhang」的價值。這將使用此樣式更新任何按鈕。

+0

我沒有看到PhoneTouchTargetOverhang「或」PhoneButtonBase「在我的項目的任何地方,我甚至grepped它。:(」風格='PhoneButtonBase'「沒有解決。 – 2010-10-19 01:21:39

+0

@MTSoul:你正在開發一個Windows Phone應用程序? – AnthonyWJones 2010-10-19 07:07:25

1

解決方法:

繪製一個矩形並添加onclick給它。