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

1.xaml

 <Window x:Class="_3D翻页动画.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:_3D翻页动画"
mc:Ignorable="d"
Topmost="True"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
RenderTransformOrigin="0.5,0.5"
AllowsTransparency="True"
Background="Transparent"
MouseLeftButtonDown="Window_MouseLeftButtonDown"
Title="MainWindow" Height="" Width="">
<!--//关键代码-->
<Window.RenderTransform>
<ScaleTransform x:Name="WindowTransform" ></ScaleTransform>
</Window.RenderTransform>
<Window.Resources>
<Style x:Key="LButton" TargetType="{x:Type Button}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="" CornerRadius="5,5,5,5" Background="{TemplateBinding Background}">
<ContentPresenter x:Name="contentPresenter"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Content="{TemplateBinding Content}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" >
</ContentPresenter>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="#8bd256"></Setter>
<Setter Property="BorderBrush" Value="#8bd256"></Setter> <Style.Triggers>
<!--鼠标移入移出-->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#11B322"></Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" Value="Gray"></Setter>
</Trigger>
</Style.Triggers>
</Style> <Storyboard x:Key="ClosedStoryboard" Storyboard.TargetName="LoginGrid">
<DoubleAnimation From="" To="" Duration="0:0:2" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[1].Offset"/>
<DoubleAnimation From="" To="" Duration="0:0:1.5" BeginTime="0:0:0.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Offset"/>
<ColorAnimation To="#00000000" Duration="" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Color"/>
</Storyboard>
<LinearGradientBrush x:Key="ClosedBrush" StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#FF000000" Offset=""/>
<GradientStop Color="#FF000000" Offset=""/>
<GradientStop Color="#FF000000" Offset=""/>
</LinearGradientBrush>
<!--//动画-->
<Storyboard x:Key="TransformToMiddle">
<DoubleAnimation Storyboard.TargetName="WindowTransform" Storyboard.TargetProperty="ScaleX" From="" To="-1" By="" Duration="0:0:1" />
</Storyboard>
<!--//动画-->
<Storyboard x:Key="TransformToMiddle1">
<DoubleAnimation Storyboard.TargetName="WindowTransform" Storyboard.TargetProperty="ScaleX" From="-1" To="" By="" Duration="0:0:1" />
</Storyboard> </Window.Resources>
<Border BorderBrush="Black" CornerRadius="" >
<Grid Name="LoginGrid" Background="Transparent" > <Grid.OpacityMask>
<LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0">
<GradientStop Color="#00000000" Offset=""/>
<GradientStop Color="#00000000" Offset=""/>
<GradientStop Color="#00000000" Offset=""/>
</LinearGradientBrush>
</Grid.OpacityMask>
<Grid.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation From="" To="" Duration="0:0:1.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[1].Offset"/>
<DoubleAnimation From="" To="" Duration="0:0:1" BeginTime="0:0:0.5" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Offset"/>
<ColorAnimation To="#FF000000" Duration="" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Color"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Grid.Triggers>
<Border BorderBrush="Black" BorderThickness="" CornerRadius="" Background="White"> <Grid Name="grid1">
<Grid.RowDefinitions>
<RowDefinition Height="62*"/>
<RowDefinition Height="103*"/>
</Grid.RowDefinitions>
<Border BorderBrush="Black" Background="#306aff" CornerRadius="10,10,0,0">
<Grid Background="Transparent">
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="">
<TextBlock Text="设置" FontSize="" Foreground="White" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"></TextBlock>
<TextBlock Text="关闭" Margin="10,0,0,0" Foreground="White" FontSize="" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown_1"></TextBlock>
</StackPanel>
</Grid>
</Border>
<Border BorderBrush="Black" BorderThickness="" Background="White" Margin="183,93,183,175" Grid.RowSpan="" CornerRadius="">
<Image Width="" Height="" Source="Images/黑马.png" ></Image>
</Border>
<StackPanel Grid.Row="" Width="" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBox Name="textBoxName" Height="" >
<TextBox.Style>
<Style TargetType="TextBox">
<Setter Property="BorderThickness" Value=""/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
<Setter Property="FontSize" Value=""></Setter>
<Setter Property="Padding" Value="10,0"/>
<Setter Property="BorderThickness" Value=""></Setter>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}" >
<Border x:Name="BackBorder" CornerRadius="" SnapsToDevicePixels="true" BorderThickness="0,0,0,1" Background="{TemplateBinding Background}" BorderBrush="#dcdcdc">
<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsFocused" Value="false"/>
<Condition Property="Text" Value=""/>
</MultiTrigger.Conditions>
<Setter Property="Background">
<Setter.Value>
<VisualBrush AlignmentX="Left" AlignmentY="Center" Stretch="None">
<VisualBrush.Visual>
<TextBlock Padding="10 2" Background="Transparent" FontSize="" Block.TextAlignment="Left" TextWrapping="Wrap" Foreground="Silver">请输入用户名</TextBlock>
</VisualBrush.Visual>
</VisualBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
<PasswordBox Name="textBoxPassword" Height="" >
<PasswordBox.Style>
<Style TargetType="PasswordBox">
<Setter Property="BorderThickness" Value=""/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="FontSize" Value=""/>
<Setter Property="Padding" Value="10,0"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="local:PasswordBoxMonitor.IsMonitoring" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type PasswordBox}">
<Border x:Name="BackBorder" CornerRadius="" SnapsToDevicePixels="true" BorderThickness="0,0,0,1" Background="{TemplateBinding Background}" BorderBrush="#dcdcdc">
<Grid VerticalAlignment="Center">
<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsFocused" Value="false"/>
<Condition Property="local:PasswordBoxMonitor.PasswordLength" Value=""/>
</MultiTrigger.Conditions>
<Setter Property="Background">
<Setter.Value>
<VisualBrush AlignmentX="Left" AlignmentY="Center" Stretch="None">
<VisualBrush.Visual>
<TextBlock Padding="10 2" Background="Transparent" FontSize="" Block.TextAlignment="Left" TextWrapping="Wrap" Foreground="Silver"><Run Text="请输入密码"/></TextBlock>
</VisualBrush.Visual>
</VisualBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</Style.Triggers>
</Style>
</PasswordBox.Style>
</PasswordBox>
<Button Height="" Content="登录" Style="{StaticResource ResourceKey=LButton}" Background="#1cc4fc" BorderBrush="#1cc4fc" Foreground="White" FontSize="" Margin="0,5,0,0"/>
</StackPanel>
</Grid>
</Border>
<Border Name="border2" BorderThickness="" BorderBrush="Black" CornerRadius="" Visibility="Hidden">
<Border.Background>
<LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,0">
<GradientStop Color="#306aff" Offset=""/>
<GradientStop Color="#779dff" Offset="0.7"/>
<GradientStop Color="White" Offset=""/>
</LinearGradientBrush>
</Border.Background>
<Grid Name="grid2" >
<Grid.RowDefinitions>
<RowDefinition Height="146*"/>
<RowDefinition Height="19*"/>
</Grid.RowDefinitions> <TextBlock Text="关闭"
Margin="" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.RowSpan=""
Foreground="White" FontSize=""
MouseLeftButtonDown="TextBlock_MouseLeftButtonDown_1"
RenderTransformOrigin="0.5,0.5">
<TextBlock.RenderTransform>
<ScaleTransform ScaleX="-1" />
</TextBlock.RenderTransform>
</TextBlock>
<Button Height="" Width="" Grid.Row=""
Content="取消" Style="{StaticResource LButton}"
RenderTransformOrigin="0.5,0.5"
Click="Button_Click_1">
<Button.RenderTransform>
<ScaleTransform ScaleX="-1" />
</Button.RenderTransform>
</Button>
</Grid>
</Border>
</Grid>
</Border>
</Window>

2.cs

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Navigation;
using System.Windows.Shapes;/// <summary>
///
/// </summary>
namespace _3D翻页动画
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
public MainWindow()
{
InitializeComponent();
myTimer.Tick += new EventHandler(timer1_Tick);
myTimer.Enabled = false;
myTimer.Interval = ; // page1.ColoedButtonClick += new EventHandler(ColoedButtonClick);
}
/// <summary>
/// 计时器
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer1_Tick(object sender, EventArgs e)
{
myTimer.Stop();
if (grid1.Visibility == Visibility.Visible)
{
grid1.Visibility = Visibility.Collapsed;
border2.Visibility = Visibility.Visible;
}
else
{
grid1.Visibility = Visibility.Visible;
border2.Visibility = Visibility.Collapsed;
}
}
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//窗体移动
if (e.ButtonState == MouseButtonState.Pressed)
{
this.DragMove();
}
}
/// <summary>
/// 设置按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Storyboard sbto = this.Resources["TransformToMiddle"] as Storyboard;
sbto.Begin(this);
myTimer.Start();
}
/// <summary>
/// 关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TextBlock_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
{
this.IsEnabled = false;
LoginGrid.OpacityMask = this.Resources["ClosedBrush"] as LinearGradientBrush;
Storyboard std = this.Resources["ClosedStoryboard"] as Storyboard;
std.Completed += delegate { this.Close(); };
std.Begin();
}
/// <summary>
/// 取消
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Storyboard sbto = this.Resources["TransformToMiddle1"] as Storyboard;
sbto.Begin(this);
myTimer.Start();
}
}
}

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. PyQt5信号与槽

    简单使用 可以使用designer的一个模式定义,也可以自己定义,在__init__函数里,self.btn.clicked.connect(self.text.clear). 注意:槽不用加括号,可 ...

  2. 【校招面试 之 网络】第1题 TCP和UDP

    TCP UDP1.TCP与UDP基本区别  (1)基于连接与无连接  (2)TCP要求系统资源较多,UDP较少:   (3)UDP程序结构较简单(头只有8个字节:源端口号.目标端口号.长度.差错)   ...

  3. 乱序字符串anagrams

    [抄题]: 给出一个字符串数组S,找到其中所有的乱序字符串(Anagram).如果一个字符串是乱序字符串,那么他存在一个字母集合相同,但顺序不同的字符串也在S中. 对于字符串数组 ["lin ...

  4. 对.NET中导出数据到EXCEL的几种方法探讨

    最近在做一个报表系统的时候,需要把DATASET中的数据导到EXCEL当中,于是在网上找了一遍,发现了好几种方法,本来以为应该差不多,但后来经过一一试用后,发现在性能上真的差别很大,现在就介绍一下,同 ...

  5. uploadify 文件上传报http 302错误

    uploadify文件上传会报http 302错误,在配置文件中将处理上传的通用类取消验证, 假设上传的通用处理类是fileUpload.ashx,则在配置文件同添加下面过滤配置能解决问题. < ...

  6. 什么是springMvc的参数绑定?

    参数绑定通俗来讲就是从页面传过来的数据通过SpringMvc进行接收.接收的数据类型可以有: (1)SpringMvc默认支持的类型:request.session.application等. (2) ...

  7. macos安装postman

    安装命令 brew cask install postman brew 是从下载源码解压然后./configure && make install,同时会包含相关依存库.并自动配置 好 ...

  8. mysql contact_ws函数 字符串被截断问题

    contact函数默认有字符串长度限制,解决方法:SET group_concat_max_len = 20000这个参数设置一下就好了

  9. ftp sftp vsftp

    ftp  sftp (secure)  是文件传输 协议 vsftp(very secure) 是 ftp 服务端 sftp 是 ssh 的一部分

  10. vertical-align和text-align

    vertical-align只适用于内联元素. 垂直对齐:vertical-align属性(转) 行高与单行纯文字的垂直居中,而如果行内含有图片和文字,在浏览器内浏览时,读者可以发现文字和图片在垂直方 ...