1. 程式人生 > >wpf 觸摸屏 button 背景為null的 問題

wpf 觸摸屏 button 背景為null的 問題

target name click com ren 內容 seo blog triggers

原文:wpf 觸摸屏 button 背景為null的 問題

<!-- button樣式-->
            <Style x:Key="myBtn" TargetType="Button" >
                <!--<Setter Property="Background" Value="{x:Null}" />-->
                <Setter Property="Background" Value="Transparent" />
                <Setter 
Property="BorderBrush" Value="White"/> <Setter Property="BorderThickness" Value="2"/> <Setter Property="Foreground" Value="White"/> <Setter Property="Template"> <Setter.Value> <
ControlTemplate TargetType="{x:Type Button}" > <Border Name="btnBorder" BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="12" Background
="{TemplateBinding Control.Background}" > <ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Border> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="Control.IsMouseOver" Value="true"> <Setter Property="Control.Background" Value="#3c4d70" /> <Setter Property="BorderThickness" Value="0"/> </Trigger> <Trigger Property="Control.IsFocused" Value="true"> <Setter Property="Control.Background" Value="#3c4d70" /> <Setter Property="BorderThickness" Value="0"/> </Trigger> </Style.Triggers> </Style>

當使用背景註釋行的 x:null 時 在觸摸屏上 必須點擊button按鈕中間的內容才有 click事件,而button 內容周圍的 區域 都無點擊效果

改為使用 Transparent 時 才能在整個button

wpf 觸摸屏 button 背景為null的 問題