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

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="" Width="">
  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="" 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="" To="" Duration="0:0:2" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[1].Offset"/>
  51. <DoubleAnimation From="" To="" Duration="0:0:1.5" BeginTime="0:0:0.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Offset"/>
  52. <ColorAnimation To="#00000000" Duration="" 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=""/>
  56. <GradientStop Color="#FF000000" Offset=""/>
  57. <GradientStop Color="#FF000000" Offset=""/>
  58. </LinearGradientBrush>
  59. <!--//动画-->
  60. <Storyboard x:Key="TransformToMiddle">
  61. <DoubleAnimation Storyboard.TargetName="WindowTransform" Storyboard.TargetProperty="ScaleX" From="" To="-1" By="" Duration="0:0:1" />
  62. </Storyboard>
  63. <!--//动画-->
  64. <Storyboard x:Key="TransformToMiddle1">
  65. <DoubleAnimation Storyboard.TargetName="WindowTransform" Storyboard.TargetProperty="ScaleX" From="-1" To="" By="" Duration="0:0:1" />
  66. </Storyboard>
  67.  
  68. </Window.Resources>
  69. <Border BorderBrush="Black" CornerRadius="" >
  70. <Grid Name="LoginGrid" Background="Transparent" >
  71.  
  72. <Grid.OpacityMask>
  73. <LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0">
  74. <GradientStop Color="#00000000" Offset=""/>
  75. <GradientStop Color="#00000000" Offset=""/>
  76. <GradientStop Color="#00000000" Offset=""/>
  77. </LinearGradientBrush>
  78. </Grid.OpacityMask>
  79. <Grid.Triggers>
  80. <EventTrigger RoutedEvent="Loaded">
  81. <EventTrigger.Actions>
  82. <BeginStoryboard>
  83. <Storyboard>
  84. <DoubleAnimation From="" To="" Duration="0:0:1.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[1].Offset"/>
  85. <DoubleAnimation From="" To="" Duration="0:0:1" BeginTime="0:0:0.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Offset"/>
  86. <ColorAnimation To="#FF000000" Duration="" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Color"/>
  87. </Storyboard>
  88. </BeginStoryboard>
  89. </EventTrigger.Actions>
  90. </EventTrigger>
  91. </Grid.Triggers>
  92. <Border BorderBrush="Black" BorderThickness="" CornerRadius="" Background="White">
  93.  
  94. <Grid Name="grid1">
  95. <Grid.RowDefinitions>
  96. <RowDefinition Height="62*"/>
  97. <RowDefinition Height="103*"/>
  98. </Grid.RowDefinitions>
  99. <Border BorderBrush="Black" Background="#306aff" CornerRadius="10,10,0,0">
  100. <Grid Background="Transparent">
  101. <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="">
  102. <TextBlock Text="设置" FontSize="" Foreground="White" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"></TextBlock>
  103. <TextBlock Text="关闭" Margin="10,0,0,0" Foreground="White" FontSize="" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown_1"></TextBlock>
  104. </StackPanel>
  105. </Grid>
  106. </Border>
  107. <Border BorderBrush="Black" BorderThickness="" Background="White" Margin="183,93,183,175" Grid.RowSpan="" CornerRadius="">
  108. <Image Width="" Height="" Source="Images/黑马.png" ></Image>
  109. </Border>
  110. <StackPanel Grid.Row="" Width="" HorizontalAlignment="Center" VerticalAlignment="Center">
  111. <TextBox Name="textBoxName" Height="" >
  112. <TextBox.Style>
  113. <Style TargetType="TextBox">
  114. <Setter Property="BorderThickness" Value=""/>
  115. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  116. <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
  117. <Setter Property="FontSize" Value=""></Setter>
  118. <Setter Property="Padding" Value="10,0"/>
  119. <Setter Property="BorderThickness" Value=""></Setter>
  120. <Setter Property="AllowDrop" Value="true"/>
  121. <Setter Property="Template">
  122. <Setter.Value>
  123. <ControlTemplate TargetType="{x:Type TextBox}" >
  124. <Border x:Name="BackBorder" CornerRadius="" SnapsToDevicePixels="true" BorderThickness="0,0,0,1" Background="{TemplateBinding Background}" BorderBrush="#dcdcdc">
  125. <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  126. </Border>
  127. </ControlTemplate>
  128. </Setter.Value>
  129. </Setter>
  130. <Style.Triggers>
  131. <MultiTrigger>
  132. <MultiTrigger.Conditions>
  133. <Condition Property="IsFocused" Value="false"/>
  134. <Condition Property="Text" Value=""/>
  135. </MultiTrigger.Conditions>
  136. <Setter Property="Background">
  137. <Setter.Value>
  138. <VisualBrush AlignmentX="Left" AlignmentY="Center" Stretch="None">
  139. <VisualBrush.Visual>
  140. <TextBlock Padding="10 2" Background="Transparent" FontSize="" Block.TextAlignment="Left" TextWrapping="Wrap" Foreground="Silver">请输入用户名</TextBlock>
  141. </VisualBrush.Visual>
  142. </VisualBrush>
  143. </Setter.Value>
  144. </Setter>
  145. </MultiTrigger>
  146. </Style.Triggers>
  147. </Style>
  148. </TextBox.Style>
  149. </TextBox>
  150. <PasswordBox Name="textBoxPassword" Height="" >
  151. <PasswordBox.Style>
  152. <Style TargetType="PasswordBox">
  153. <Setter Property="BorderThickness" Value=""/>
  154. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  155. <Setter Property="VerticalContentAlignment" Value="Center"/>
  156. <Setter Property="FontSize" Value=""/>
  157. <Setter Property="Padding" Value="10,0"/>
  158. <Setter Property="AllowDrop" Value="true"/>
  159. <Setter Property="local:PasswordBoxMonitor.IsMonitoring" Value="True"/>
  160. <Setter Property="Template">
  161. <Setter.Value>
  162. <ControlTemplate TargetType="{x:Type PasswordBox}">
  163. <Border x:Name="BackBorder" CornerRadius="" SnapsToDevicePixels="true" BorderThickness="0,0,0,1" Background="{TemplateBinding Background}" BorderBrush="#dcdcdc">
  164. <Grid VerticalAlignment="Center">
  165. <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  166. </Grid>
  167. </Border>
  168. </ControlTemplate>
  169. </Setter.Value>
  170. </Setter>
  171. <Style.Triggers>
  172. <MultiTrigger>
  173. <MultiTrigger.Conditions>
  174. <Condition Property="IsFocused" Value="false"/>
  175. <Condition Property="local:PasswordBoxMonitor.PasswordLength" Value=""/>
  176. </MultiTrigger.Conditions>
  177. <Setter Property="Background">
  178. <Setter.Value>
  179. <VisualBrush AlignmentX="Left" AlignmentY="Center" Stretch="None">
  180. <VisualBrush.Visual>
  181. <TextBlock Padding="10 2" Background="Transparent" FontSize="" Block.TextAlignment="Left" TextWrapping="Wrap" Foreground="Silver"><Run Text="请输入密码"/></TextBlock>
  182. </VisualBrush.Visual>
  183. </VisualBrush>
  184. </Setter.Value>
  185. </Setter>
  186. </MultiTrigger>
  187. </Style.Triggers>
  188. </Style>
  189. </PasswordBox.Style>
  190. </PasswordBox>
  191. <Button Height="" Content="登录" Style="{StaticResource ResourceKey=LButton}" Background="#1cc4fc" BorderBrush="#1cc4fc" Foreground="White" FontSize="" Margin="0,5,0,0"/>
  192. </StackPanel>
  193. </Grid>
  194. </Border>
  195. <Border Name="border2" BorderThickness="" BorderBrush="Black" CornerRadius="" Visibility="Hidden">
  196. <Border.Background>
  197. <LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0">
  198. <GradientStop Color="#306aff" Offset=""/>
  199. <GradientStop Color="#779dff" Offset="0.7"/>
  200. <GradientStop Color="White" Offset=""/>
  201. </LinearGradientBrush>
  202. </Border.Background>
  203. <Grid Name="grid2" >
  204. <Grid.RowDefinitions>
  205. <RowDefinition Height="146*"/>
  206. <RowDefinition Height="19*"/>
  207. </Grid.RowDefinitions>
  208.  
  209. <TextBlock Text="关闭"
  210. Margin="" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.RowSpan=""
  211. Foreground="White" FontSize=""
  212. MouseLeftButtonDown="TextBlock_MouseLeftButtonDown_1"
  213. RenderTransformOrigin="0.5,0.5">
  214. <TextBlock.RenderTransform>
  215. <ScaleTransform ScaleX="-1" />
  216. </TextBlock.RenderTransform>
  217. </TextBlock>
  218. <Button Height="" Width="" Grid.Row=""
  219. Content="取消"
  220.  
  221. Style="{StaticResource LButton}"
  222. RenderTransformOrigin="0.5,0.5"
  223. Click="Button_Click_1">
  224. <Button.RenderTransform>
  225. <ScaleTransform ScaleX="-1" />
  226. </Button.RenderTransform>
  227. </Button>
  228. </Grid>
  229. </Border>
  230. </Grid>
  231. </Border>
  232. </Window>

2.cs

  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 = ;
  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. }

wpf 窗体翻页效果的更多相关文章

  1. webapp应用--模拟电子书翻页效果

    前言: 现在移动互联网发展火热,手机上网的用户越来越多,甚至大有超过pc访问的趋势.所以,用web程序做出仿原生效果的移动应用,也变得越来越流行了.这种程序也就是我们常说的单页应用程序,它也有一个英文 ...

  2. 采用cocos2d-x lua 的listview 实现pageview的翻页效果之上下翻页效果

    --翻页滚动效果local function fnScrollViewScrolling( sender,eventType)    -- body    if eventType == 10 the ...

  3. css实现翻页效果

    如图,鼠标移动到图上,实现右上角翻页的效果,本例主要border边框的设置. 一.基本概念 <html> <head> <style> #demo{ width:0 ...

  4. turn.js 图书翻页效果

    今天用turn.js 做图书的翻页效果遇到问题: 图片路径总是出错 调了一天,总算调出来了 我用的thinkphp,其他的不知道是不是一样 三 个地方要改动: 1.后台查出地址 注意的地方:1.地址要 ...

  5. (旧)子数涵数·PS ——翻页效果

    一.首先在网络上下载一张图片,作为素材.这是我下载的素材,至于为什么选择这张照片呢,当然不是因为自己的一些羞羞的念头啦. 二.打开Photoshop,我使用的版本是CS3(因为CS3所占的磁盘空间较小 ...

  6. ajax翻页效果模仿yii框架

    ajax翻页效果,模仿yii框架. 复制代码代码如下: <!DOCTYPE html>  <html>  <head>  <title>ajax分页_w ...

  7. 纯css3写的仿真图书翻页效果

    对css3研究越深入,越觉得惊艳.css3说不上是万能的,但是它能实现的效果也超出了我的想象.它的高效率和动画效果的流畅性很多情况下能替代js的作用.个人习惯css3能实现的效果就不会用js,虽然在国 ...

  8. Android 实现书籍翻页效果----完结篇

    By 何明桂(http://blog.csdn.net/hmg25) 转载请注明出处 之前由于种种琐事,暂停了这个翻页效果的实现,终于在这周末完成了大部分功能,但是这里只是给出了一个基本的雏形,没有添 ...

  9. Android 实现书籍翻页效果----升级篇

    自从之前发布了<Android 实现书籍翻页效果----完结篇 >之后,收到了很多朋友给我留言,前段时间由于事情较多,博客写得太匆忙很多细节地方没有描述清楚.所以不少人对其中的地方有不少不 ...

随机推荐

  1. 使用生活实例理解Asp.net运行时

    学习编程语言,掌握面向对象的编程思想尤为重要,一旦理解了面向对象的这种概念,那么好些地方拿到生活中去理解,就容易的多了.书本上的枯燥干涩的语言,对于好多人来说,即难懂,更难长时间牢牢记得.但是编程语言 ...

  2. CentOS设置yum存储库 (nginx)

    要为RHEL / CentOS设置yum存储库,请创建/etc/yum.repos.d/nginx.repo 使用以下内容命名的文件 : [nginx] name=nginx repo baseurl ...

  3. 演示Spring框架的JDBC模板的简单操作

    1. 步骤一:创建数据库的表结构 create database spring_day03; use spring_day03; create table t_account( id int prim ...

  4. python中的日志模块logging

    1.日志级别5个: 警告Warning 一般信息Info  调试 Debug  错误Error 致命Critical 2.禁用日志方法 logging.disable(logging.DEBUG) 3 ...

  5. ubuntu 设置静态ip地址不生效问题

    出现了一个问题是,配置了静态ip地址之后,重启网络服务,查看ip地址是生效的,过会再看就 不生效了,查看网上说是由于 network-manager 管理ip地址时候出现的冲突,将network-ma ...

  6. msys2 git status显示中文文件名问题

    git config [--global] core.quotepath off https://stackoverflow.com/questions/5854967/git-msysgit-acc ...

  7. 《Just for Fun》---读后感

    <Just for Fun>本书是Linux之父林纳斯自传,书名的意思是:只是为了好玩.主要是讲了林纳斯的人生经历,以及Linux的诞生过程.Linux从一个终端仿真器到一个世界瞩目的操作 ...

  8. EPLAN 软件平台中的词“点“大全

    1. 中断点(Interruption Point):     在原理图绘制时,如果当前绘图区域的空间不足,需要转到其它页面继续绘制,而这两页之间存在连续的“信息流“时,可以使用“中断点“来传递这种“ ...

  9. 2018.09.06 烽火传递(单调队列优化dp)

    描述 烽火台是重要的军事防御设施,一般建在交通要道或险要处.一旦有军情发生,则白天用浓烟,晚上有火光传递军情. 在某两个城市之间有 n 座烽火台,每个烽火台发出信号都有一定的代价.为了使情报准确传递, ...

  10. Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable t

    spring与hibernate整合然后出现如下错误: org.springframework.beans.factory.BeanCreationException: Error creating ...