wpf 类似TextBlock外观的Button的样式

  <Style x:Key="noborderbtnStyle" TargetType="{x:Type Button}">
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid x:Name="grid" Background="#00000000">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver"/>
                                    <VisualState x:Name="Pressed"/>
                                    <VisualState x:Name="Disabled"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <ContentPresenter Margin="0" Opacity="1" HorizontalAlignment="Center"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsFocused" Value="True"/>
                            <Trigger Property="IsDefaulted" Value="True"/>
                            <Trigger Property="IsMouseOver" Value="True"/>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="Background" TargetName="grid" Value="#FF0A861A"/>
                                <Setter Property="Opacity" TargetName="grid" Value="0.565"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False"/>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <!--<Setter Property="MinWidth" Value="118"/>-->
        </Style>

 

posted @ 2015-09-20 10:32  秋刀鱼No1  阅读(1321)  评论(0编辑  收藏  举报