WPF按钮清空自带样式,以及透明按钮时,Grid的Background属性设置引起"点击"问题.

 1.空样式按钮

<Style x:Key="EmptyButtonStyle" TargetType="Button">
            <Setter Property="Padding" Value="0"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <ContentPresenter Content="{TemplateBinding Content}"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    <Button Width="50" Height="50" HorizontalAlignment="Left" Margin="4,0,0,0" Style="{StaticResource EmptyButtonStyle}" >
              <Image Source="Styles/Images/KaraokeElibrary/button_left_normalmode.png"></

2.透明样式按钮

<Style x:Key="TransparentButtonStyle" TargetType="Button">
            <Setter Property="Padding" Value="0"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Background="Transparent"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
ControlTemplate内的Grid如果不设置Background属性,则按钮Button的Click不会触发!
如 
<ControlTemplate TargetType="Button">
                        <Grid  />
                    </ControlTemplate>
 
上一篇:完美解决eWebEditor编辑器按钮失效 IE8、9无法使用方法


下一篇:jQuery点击一次按钮提交多个表单带来的问题