WPF之Button

2017-06-23 11:29:37来源:CSDN作者:qq_23018459人点击

  <Style x:Key="LoginButtonStyle" TargetType="{x:Type Button}">
            <Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}"/>
            <Setter Property="Background" Value="#09A3DC"/>
            <Setter Property="BorderBrush" Value="#09A3DC"/>
            <Setter Property="Foreground" Value="#FFFFFF"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Padding" Value="1"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border x:Name="border"  BorderThickness="0"  SnapsToDevicePixels="True" Background="#09A3DC" CornerRadius="5">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0:0:0.5">
                                            <VisualTransition.GeneratedEasingFunction>
                                                <CircleEase EasingMode="EaseOut"/>
                                            </VisualTransition.GeneratedEasingFunction>
                                        </VisualTransition>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource LoginButton.Hover.Brush}"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource LoginButton.Peessed.Brush}"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="0.5"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>                            <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

  <!--<Button x:Name="btnLogin" Click="btnLogin_Click" KeyboardNavigation.TabIndex="6" FontSize="18" Style="{DynamicResource LoginButtonStyle}" Width="224" Height="41" Canvas.Left="156" Canvas.Top="147">
                                <StackPanel Orientation="Horizontal">
                                    <Label Foreground="White">安 全 登 录</Label>
                                </StackPanel>
                            </Button>-->

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台