wpf 窗体翻页效果

摘要:
Stylex;SetterProperty=“BorderBrush”值=“#8bd256”>TriggerProperty=“IsMouseOver”值=“True”>SetterProperty=“Background”值=“#11B322”>TriggerProperty=“IsEnabled”值=“false”>44<&书信电报;

点击设置翻页,取消翻回来

1.xaml

  1 <Window x:Class="_3D翻页动画.MainWindow"
  2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6         xmlns:local="clr-namespace:_3D翻页动画"
  7         mc:Ignorable="d"
  8         Topmost="True"
  9         WindowStartupLocation="CenterScreen"
 10         WindowStyle="None"
 11         RenderTransformOrigin="0.5,0.5"
 12         AllowsTransparency="True"  
 13    Background="Transparent"
 14         MouseLeftButtonDown="Window_MouseLeftButtonDown"
 15         Title="MainWindow" Height="330" Width="428">
 16     <!--//关键代码-->
 17     <Window.RenderTransform>
 18         <ScaleTransform x:Name="WindowTransform" ></ScaleTransform>
 19     </Window.RenderTransform>
 20     <Window.Resources>
 21         <Style x:Key="LButton" TargetType="{x:Type Button}" >
 22             <Setter Property="Template">
 23                 <Setter.Value>
 24                     <ControlTemplate TargetType="{x:Type Button}">
 25                         <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" CornerRadius="5,5,5,5" Background="{TemplateBinding Background}">
 26                             <ContentPresenter x:Name="contentPresenter"                                               
 27                                               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
 28                                               Content="{TemplateBinding Content}"                                                                                                                          
 29                                               VerticalAlignment="{TemplateBinding VerticalContentAlignment}"  >
 30                             </ContentPresenter>
 31                         </Border>
 32                     </ControlTemplate>
 33                 </Setter.Value>
 34             </Setter>
 35             <Setter Property="Background"  Value="#8bd256"></Setter>
 36             <Setter Property="BorderBrush" Value="#8bd256"></Setter>
 37 
 38             <Style.Triggers>
 39                 <!--鼠标移入移出-->
 40                 <Trigger Property="IsMouseOver" Value="True">
 41                     <Setter Property="Background" Value="#11B322"></Setter>
 42                 </Trigger>
 43                 <Trigger Property="IsEnabled" Value="false">
 44                     <Setter Property="Background" Value="Gray"></Setter>
 45                 </Trigger>
 46             </Style.Triggers>
 47         </Style>
 48 
 49         <Storyboard x:Key="ClosedStoryboard" Storyboard.TargetName="LoginGrid">
 50             <DoubleAnimation From="1" To="0" Duration="0:0:2" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[1].Offset"/>
 51             <DoubleAnimation From="1" To="0" Duration="0:0:1.5" BeginTime="0:0:0.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Offset"/>
 52             <ColorAnimation To="#00000000" Duration="0" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Color"/>
 53         </Storyboard>
 54         <LinearGradientBrush x:Key="ClosedBrush" StartPoint="0.5,0" EndPoint="0.5,1">
 55             <GradientStop Color="#FF000000" Offset="0"/>
 56             <GradientStop Color="#FF000000" Offset="1"/>
 57             <GradientStop Color="#FF000000" Offset="1"/>
 58         </LinearGradientBrush>
 59         <!--//动画-->
 60         <Storyboard x:Key="TransformToMiddle">
 61             <DoubleAnimation Storyboard.TargetName="WindowTransform" Storyboard.TargetProperty="ScaleX"  From="1" To="-1" By="1" Duration="0:0:1" />
 62         </Storyboard>
 63         <!--//动画-->
 64         <Storyboard x:Key="TransformToMiddle1">
 65             <DoubleAnimation Storyboard.TargetName="WindowTransform" Storyboard.TargetProperty="ScaleX"  From="-1" To="1" By="1" Duration="0:0:1" />
 66         </Storyboard>
 67 
 68 
 69     </Window.Resources>
 70     <Border  BorderBrush="Black"  CornerRadius="10" >
 71         <Grid Name="LoginGrid" Background="Transparent" >
 72 
 73             <Grid.OpacityMask>
 74             <LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0">
 75                 <GradientStop Color="#00000000" Offset="0"/>
 76                 <GradientStop Color="#00000000" Offset="1"/>
 77                 <GradientStop Color="#00000000" Offset="1"/>
 78             </LinearGradientBrush>
 79         </Grid.OpacityMask>
 80         <Grid.Triggers>
 81             <EventTrigger RoutedEvent="Loaded">
 82                 <EventTrigger.Actions>
 83                     <BeginStoryboard>
 84                         <Storyboard>
 85                             <DoubleAnimation From="1" To="0" Duration="0:0:1.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[1].Offset"/>
 86                             <DoubleAnimation From="1" To="0" Duration="0:0:1" BeginTime="0:0:0.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Offset"/>
 87                             <ColorAnimation To="#FF000000" Duration="0" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Color"/>
 88                         </Storyboard>
 89                     </BeginStoryboard>
 90                 </EventTrigger.Actions>
 91             </EventTrigger>
 92         </Grid.Triggers>
 93             <Border BorderBrush="Black" BorderThickness="1"  CornerRadius="10" Background="White">
 94 
 95                 <Grid Name="grid1">
 96                     <Grid.RowDefinitions>
 97                         <RowDefinition Height="62*"/>
 98                         <RowDefinition Height="103*"/>
 99                     </Grid.RowDefinitions>
100                     <Border BorderBrush="Black"  Background="#306aff" CornerRadius="10,10,0,0">
101                         <Grid Background="Transparent">
102                             <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="5">
103                                 <TextBlock Text="设置"  FontSize="15"  Foreground="White" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"></TextBlock>
104                                 <TextBlock Text="关闭" Margin="10,0,0,0" Foreground="White" FontSize="15" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown_1"></TextBlock>
105                             </StackPanel>
106                         </Grid>
107                     </Border>
108                     <Border BorderBrush="Black" BorderThickness="1" Background="White" Margin="183,93,183,175" Grid.RowSpan="2"  CornerRadius="30">
109                         <Image Width="60" Height="60"  Source="Images/黑马.png" ></Image>
110                     </Border>
111                     <StackPanel Grid.Row="1" Width="280" HorizontalAlignment="Center" VerticalAlignment="Center">
112                         <TextBox Name="textBoxName" Height="38"  >
113                             <TextBox.Style>
114                                 <Style TargetType="TextBox">
115                                     <Setter Property="BorderThickness" Value="1"/>
116                                     <Setter Property="HorizontalContentAlignment" Value="Left"/>
117                                     <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
118                                     <Setter Property="FontSize" Value="18"></Setter>
119                                     <Setter Property="Padding" Value="10,0"/>
120                                     <Setter Property="BorderThickness" Value="1"></Setter>
121                                     <Setter Property="AllowDrop" Value="true"/>
122                                     <Setter Property="Template">
123                                         <Setter.Value>
124                                             <ControlTemplate TargetType="{x:Type TextBox}" >
125                                                 <Border x:Name="BackBorder" CornerRadius="0" SnapsToDevicePixels="true" BorderThickness="0,0,0,1" Background="{TemplateBinding Background}" BorderBrush="#dcdcdc">
126                                                     <ScrollViewer x:Name="PART_ContentHost"  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
127                                                 </Border>
128                                             </ControlTemplate>
129                                         </Setter.Value>
130                                     </Setter>
131                                     <Style.Triggers>
132                                         <MultiTrigger>
133                                             <MultiTrigger.Conditions>
134                                                 <Condition Property="IsFocused" Value="false"/>
135                                                 <Condition Property="Text" Value=""/>
136                                             </MultiTrigger.Conditions>
137                                             <Setter Property="Background">
138                                                 <Setter.Value>
139                                                     <VisualBrush AlignmentX="Left"  AlignmentY="Center" Stretch="None">
140                                                         <VisualBrush.Visual>
141                                                             <TextBlock Padding="10 2" Background="Transparent" FontSize="18"  Block.TextAlignment="Left"  TextWrapping="Wrap"  Foreground="Silver">请输入用户名</TextBlock>
142                                                         </VisualBrush.Visual>
143                                                     </VisualBrush>
144                                                 </Setter.Value>
145                                             </Setter>
146                                         </MultiTrigger>
147                                     </Style.Triggers>
148                                 </Style>
149                             </TextBox.Style>
150                         </TextBox>
151                         <PasswordBox Name="textBoxPassword" Height="38"  >
152                             <PasswordBox.Style>
153                                 <Style TargetType="PasswordBox">
154                                     <Setter Property="BorderThickness" Value="1"/>
155                                     <Setter Property="HorizontalContentAlignment" Value="Left"/>
156                                     <Setter Property="VerticalContentAlignment" Value="Center"/>
157                                     <Setter Property="FontSize" Value="18"/>
158                                     <Setter Property="Padding" Value="10,0"/>
159                                     <Setter Property="AllowDrop" Value="true"/>
160                                     <Setter Property="local:PasswordBoxMonitor.IsMonitoring" Value="True"/>
161                                     <Setter Property="Template">
162                                         <Setter.Value>
163                                             <ControlTemplate TargetType="{x:Type PasswordBox}">
164                                                 <Border x:Name="BackBorder" CornerRadius="0" SnapsToDevicePixels="true"  BorderThickness="0,0,0,1" Background="{TemplateBinding Background}" BorderBrush="#dcdcdc">
165                                                     <Grid VerticalAlignment="Center">
166                                                         <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
167                                                     </Grid>
168                                                 </Border>
169                                             </ControlTemplate>
170                                         </Setter.Value>
171                                     </Setter>
172                                     <Style.Triggers>
173                                         <MultiTrigger>
174                                             <MultiTrigger.Conditions>
175                                                 <Condition Property="IsFocused" Value="false"/>
176                                                 <Condition Property="local:PasswordBoxMonitor.PasswordLength" Value="0"/>
177                                             </MultiTrigger.Conditions>
178                                             <Setter Property="Background">
179                                                 <Setter.Value>
180                                                     <VisualBrush AlignmentX="Left"  AlignmentY="Center" Stretch="None">
181                                                         <VisualBrush.Visual>
182                                                             <TextBlock Padding="10 2" Background="Transparent" FontSize="18"  Block.TextAlignment="Left"  TextWrapping="Wrap"  Foreground="Silver"><Run Text="请输入密码"/></TextBlock>
183                                                         </VisualBrush.Visual>
184                                                     </VisualBrush>
185                                                 </Setter.Value>
186                                             </Setter>
187                                         </MultiTrigger>
188                                     </Style.Triggers>
189                                 </Style>
190                             </PasswordBox.Style>
191                         </PasswordBox>
192                         <Button Height="38" Content="登录" Style="{StaticResource ResourceKey=LButton}" Background="#1cc4fc" BorderBrush="#1cc4fc" Foreground="White" FontSize="18" Margin="0,5,0,0"/>
193                     </StackPanel>
194                 </Grid>
195             </Border>
196             <Border Name="border2" BorderThickness="1" BorderBrush="Black"  CornerRadius="10" Visibility="Hidden">
197                 <Border.Background>
198                     <LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0">
199                         <GradientStop Color="#306aff" Offset="1"/>
200                         <GradientStop Color="#779dff" Offset="0.7"/>
201                         <GradientStop Color="White" Offset="0"/>
202                     </LinearGradientBrush>
203                 </Border.Background>
204                 <Grid Name="grid2" >
205                     <Grid.RowDefinitions>
206                         <RowDefinition Height="146*"/>
207                         <RowDefinition Height="19*"/>
208                     </Grid.RowDefinitions>
209 
210                     <TextBlock Text="关闭"
211                                Margin="5" VerticalAlignment="Top" HorizontalAlignment="Left"  Grid.RowSpan="2"
212                                Foreground="White" FontSize="15" 
213                                MouseLeftButtonDown="TextBlock_MouseLeftButtonDown_1" 
214                                RenderTransformOrigin="0.5,0.5">
215                         <TextBlock.RenderTransform>
216                             <ScaleTransform ScaleX="-1" />
217                         </TextBlock.RenderTransform>
218                     </TextBlock>
219                     <Button Height="30" Width="60"  Grid.Row="1"
220                             Content="取消"
221                             
222                             Style="{StaticResource LButton}"
223                             RenderTransformOrigin="0.5,0.5" 
224                             Click="Button_Click_1">
225                         <Button.RenderTransform>
226                             <ScaleTransform ScaleX="-1" />
227                         </Button.RenderTransform>
228                     </Button>
229                 </Grid>
230             </Border>
231         </Grid>
232     </Border>
233 </Window>

2.cs

wpf 窗体翻页效果第1张wpf 窗体翻页效果第2张
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 using System.Windows;
 7 using System.Windows.Controls;
 8 using System.Windows.Data;
 9 using System.Windows.Documents;
10 using System.Windows.Input;
11 using System.Windows.Media;
12 using System.Windows.Media.Animation;
13 using System.Windows.Media.Imaging;
14 using System.Windows.Media.Media3D;
15 using System.Windows.Navigation;
16 using System.Windows.Shapes;/// <summary>
17 /// 
18 /// </summary>
19 namespace _3D翻页动画
20 {
21     /// <summary>
22     /// MainWindow.xaml 的交互逻辑
23     /// </summary>
24     public partial class MainWindow : Window
25     {
26         System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
27         public MainWindow()
28         {
29             InitializeComponent();
30             myTimer.Tick += new EventHandler(timer1_Tick);
31             myTimer.Enabled = false;
32             myTimer.Interval = 500;
33 
34             //  page1.ColoedButtonClick += new EventHandler(ColoedButtonClick);
35         }
36         /// <summary>
37         /// 计时器
38         /// </summary>
39         /// <param name="sender"></param>
40         /// <param name="e"></param>
41         private void timer1_Tick(object sender, EventArgs e)
42         {
43             myTimer.Stop();
44             if (grid1.Visibility == Visibility.Visible)
45             {
46                 grid1.Visibility = Visibility.Collapsed;
47                 border2.Visibility = Visibility.Visible;
48             }
49             else
50             {
51                 grid1.Visibility = Visibility.Visible;
52                 border2.Visibility = Visibility.Collapsed;
53             }
54         }    
55         private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
56         {
57             //窗体移动
58             if (e.ButtonState == MouseButtonState.Pressed)
59             {
60                 this.DragMove();
61             }
62         }
63         /// <summary>
64         /// 设置按钮
65         /// </summary>
66         /// <param name="sender"></param>
67         /// <param name="e"></param>
68         private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
69         {
70             Storyboard sbto = this.Resources["TransformToMiddle"] as Storyboard;
71             sbto.Begin(this);
72             myTimer.Start();
73         }
74         /// <summary>
75         /// 关闭窗口
76         /// </summary>
77         /// <param name="sender"></param>
78         /// <param name="e"></param>
79         private void TextBlock_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
80         {
81             this.IsEnabled = false;
82             LoginGrid.OpacityMask = this.Resources["ClosedBrush"] as LinearGradientBrush;
83             Storyboard std = this.Resources["ClosedStoryboard"] as Storyboard;
84             std.Completed += delegate { this.Close(); };
85             std.Begin();
86         }
87         /// <summary>
88         /// 取消
89         /// </summary>
90         /// <param name="sender"></param>
91         /// <param name="e"></param>
92         private void Button_Click_1(object sender, RoutedEventArgs e)
93         {
94             Storyboard sbto = this.Resources["TransformToMiddle1"] as Storyboard;
95             sbto.Begin(this);
96             myTimer.Start();
97         }
98     }
99 }
View Code

免责声明:文章转载自《wpf 窗体翻页效果》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇GPU 显存释放socket选项总结(setsocketopt)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

vscode 对于 C 源文件,IntelliSenseMode 已根据编译器参数和探测 compilerPath 从“clang-x64”更改为“gcc-x64”

vscode 不知道从什么时候开始出现 对于 C 源文件,IntelliSenseMode 已根据编译器参数和探测 compilerPath 从“clang-x64”更改为“gcc-x64” 的信息 解决方案 .vscode 文件夹 -> c_cpp_properties.json 文件 -> 将 "intelliSenseMode": "cl...

Guava之缓存

一、使用场景   Guava Cache是本地缓存,当数据被重复查询多次,愿意耗费一些内存空间来减少查询的操作提高查询的速度,就可以使用Guava Cache。 二、使用方式 1.创建     LoadingCache是附带CacheLoader构建而成的缓存实现。创建自己的CacheLoader通常只需要简单地实现V load(K key) throw...

通达OA 11.5 SQL注入漏洞复现

0x00 漏洞描述  通达OA 11.5存在sql注入 0x01 漏洞影响版本  通达oa 11.5 0x02 漏洞复现 1、下载通达OA 11.5 https://cdndown.tongda2000.com/oa/2019/TDOA11.5.exe,点击安装 2、创建一个普通账户test:test123456 3.1、id参数存在sql注入 利用条...

android登录实现,存储数据到/data/data/包名/info.txt

1.一个简单登录界面布局代码如下: @1采用线性布局加相对布局方式 @2线性布局采用垂直排列 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:t...

JNI数据类型(转)

  本文原创,转载请注明出处:http://blog.csdn.net/qinjuning     在Java存在两种数据类型: 基本类型 和 引用类型 ,大家都懂的 。     在JNI的世界里也存在类似的数据类型,与Java比较起来,其范围更具严格性,如下:         1、primitive types ----基本数据类型,如:int、 flo...

vant+vue控制列表展开

<van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad"...