WPF效果第一百九十三篇之登录实现

Posted dotNET跨平台

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WPF效果第一百九十三篇之登录实现相关的知识,希望对你有一定的参考价值。

前面一直在玩耍ListBox(最爱),大周末的就适合在家吹着风扇撸着代码;今天来分享一个很简单实用的登录,来看看最终实现的效果:

1、关于软件启动后焦点实现:

<Style TargetType="Border">
    <Style.Triggers>
        <DataTrigger Binding="Binding IsEmptyAccount,Mode=TwoWay" Value="true">
            <Setter Property="FocusManager.FocusedElement" Value="Binding ElementName=UserNameTxb"/>
        </DataTrigger>
    </Style.Triggers>
</Style>

2、关于启动窗口动画:

<Storyboard x:Key="LoadStoryboard">
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="LoginWindow">
        <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
        <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1"/>
    </DoubleAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LoginWindow"
                                   Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
        <SplineDoubleKeyFrame KeyTime="00:00:0" Value="0"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.6" Value="1"/>
    </DoubleAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LoginWindow"
                                   Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
        <SplineDoubleKeyFrame KeyTime="00:00:0" Value="0"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.6" Value="1"/>
    </DoubleAnimationUsingKeyFrames>
</Storyboard>

3、关于窗口抖动动画:

<Storyboard x:Key="ShakeStoryboard" Completed="ShakeStoryboard_Completed">
    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot"
                                   Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
        <SplineDoubleKeyFrame KeyTime="00:00:0" Value="1"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.2" Value="0.7"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.4" Value="0.8"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.5" Value="0.9"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.6" Value="1"/>
    </DoubleAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot"
                                   Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
        <SplineDoubleKeyFrame KeyTime="00:00:0" Value="1"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.2" Value="0.7"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.4" Value="0.8"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.5" Value="0.9"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.6" Value="1"/>
    </DoubleAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetName="LayoutRoot"
                                   Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
        <SplineDoubleKeyFrame KeyTime="00:00:0.2" Value="10"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.3" Value="-20"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.4" Value="10"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.5" Value="-16"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.6" Value="10"/>
        <SplineDoubleKeyFrame KeyTime="00:00:0.7" Value="0"/>
    </DoubleAnimationUsingKeyFrames>
</Storyboard>

最终简单的效果先这样吧;以后有时间的话,可以再去摸索一下更复杂的效果;编程不息、Bug不止、无Bug、无生活;改bug的冷静、编码的激情、完成后的喜悦、挖坑的激动 、填坑的兴奋;这也许就是屌丝程序员的乐趣吧;今天就到这里吧;希望自己有动力一步一步坚持下去;生命不息,代码不止;大家抽空可以看看今天分享的效果,有好的意见和想法,可以在留言板随意留言;我看到后会第一时间回复大家,多谢大家的一直默默的关注和支持!如果觉得不错,那就伸出您的小手点个赞并关注一下!

以上是关于WPF效果第一百九十三篇之登录实现的主要内容,如果未能解决你的问题,请参考以下文章

WPF效果第一百九十八篇之模块对比

WPF效果第一百九十四篇之伸缩面板

WPF效果第一百九十篇之再耍ListBox

WPF效果第一百九十一篇之框选ListBox

WPF效果第一百九十二篇之TreeView支持多选

WPF效果第一百九十九篇之Gamma曲线