WP7删除黑色边框

问题描述:

我一直在努力寻找这个退出了很长一段时间。WP7删除黑色边框

Windows在按钮组件周围添加了黑色(或透明)边框。原因是按钮的触摸区域有点大,因此点击按钮更容易。

在我的应用程序中,我真的需要删除该区域。我尝试了很多,但似乎是无法实现的。我也尝试过Expression Blend,但没有运气。

<Style x:Key="ButtonStyleCalendar" TargetType="Button"> 
     <Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/> 
     <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/> 
     <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/> 
     <Setter Property="BorderThickness" Value="0"/> 
     <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeSmall}"/> 
     <Setter Property="Padding" Value="0"/> 
     <Setter Property="Margin" Value="0" /> 
     <Setter Property="VerticalContentAlignment" Value="Top" /> 
    </Style> 

这是我应用于按钮的样式。我认为这将是保证金或填充,但不是这样。

有没有人有这个答案?我搜索了stackoverflow,但没有人提出解决方案。

在此先感谢!

您需要覆盖按钮的ControlTemplate并删除Margin="{StaticResource PhoneTouchTargetOverhang}"。这是由此产生的风格:

<Style x:Key="ButtonStyleCalendar" TargetType="Button"> 
    <Setter Property="Background" Value="Transparent"/> 
    <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/> 
    <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/> 
    <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/> 
    <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/> 
    <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/> 
    <Setter Property="Padding" Value="10,3,10,5"/> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="Button"> 
       <Grid Background="Transparent"> 
        <Border x:Name="ButtonBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="0" > 
         <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> 
        </Border> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 
+0

非常感谢!这就像一个魅力:)。 – SamVerschueren

+0

@Unknown让此答案。将帮助奥利弗以及其他谁遇到这个问题。 –