自己写的wpf 弹出框,欢迎拍砖,动画都写在了后台代码,前台代码不太重要,用了一下iconfont,具体样式我就不贴出来了,本次主要是后台代码的动画

需要有父级窗口才可以使用。

前台代码:

<Window x:Class="V2VReporter.Views.SystemViews.MsgPopup"
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:V2VReporter.Views.SystemViews"
xmlns:controls="clr-namespace:V2VReporter.Controls"
mc:Ignorable="d"
Title="系统消息" Height="230" Width="300" AllowsTransparency="True" WindowStyle="None" ShowInTaskbar="False">
<Border BorderBrush="{StaticResource SideLevel1}" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="{StaticResource MainGreen}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<TextBlock Text="" Style="{StaticResource IconFont}" VerticalAlignment="Center" FontSize="18" Foreground="AliceBlue" Margin="5,0,0,0"></TextBlock>
<TextBlock Text="系统消息" Foreground="AliceBlue" FontSize="15" VerticalAlignment="Center" Margin="2,0,0,0" ></TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" HorizontalAlignment="Right">
<controls:IconButton Style="{StaticResource TitleCloseBtn}" Margin="0,5,2,0" Click="ButtonBase_OnClick"></controls:IconButton>
</StackPanel>
</Grid>
</Grid>
</Border>
</Window>

后台代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
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.Shapes;
using V2VReporter.Resource; namespace V2VReporter.Views.SystemViews
{
/// <summary>
/// MsgPopup.xaml 的交互逻辑
/// </summary>
public partial class MsgPopup:Window
{
/// <summary>
/// 关闭动画
/// </summary>
private Storyboard sb_close=new Storyboard();
/// <summary>
/// 关闭标识
/// </summary>
private bool close_flg = false;
/// <summary>
/// 关闭动画
/// </summary>
private DoubleAnimation close=new DoubleAnimation();
/// <summary>
/// 窗口弹出
/// </summary>
private Storyboard sb_loaded=new Storyboard();
/// <summary>
/// 窗口弹出动画
/// </summary>
private DoubleAnimation load=new DoubleAnimation();
/// <summary>
/// 窗口加载动画
/// </summary>
private DoubleAnimation loadOp=new DoubleAnimation(); public MsgPopup(Window win)
{
InitializeComponent(); initedCloseStory();
initedLoadStory(win);
sb_loaded.Begin();
} private void initedLoadStory(Window win)
{
this.Owner = win;
this.Left = win.Width - this.Width;
load.From = win.Height;
load.To = win.Height - this.Height;
load.Duration = new Duration(TimeSpan.FromSeconds(1.5));
load.FillBehavior = FillBehavior.HoldEnd;
load.AutoReverse = false;
sb_loaded.Children.Add(load);
Storyboard.SetTarget(load, this);
Storyboard.SetTargetProperty(load, new PropertyPath("Top")); loadOp.From = ;
loadOp.To = ;
loadOp.Duration=new Duration(TimeSpan.FromSeconds(1.5));
loadOp.FillBehavior = FillBehavior.HoldEnd;
loadOp.AutoReverse = false;
sb_loaded.Children.Add(loadOp);
Storyboard.SetTarget(loadOp, this);
Storyboard.SetTargetProperty(loadOp, new PropertyPath("Opacity")); } private void initedCloseStory()
{
close.From = ;
close.To = ;
close.Duration = new Duration(TimeSpan.FromSeconds());
close.FillBehavior = FillBehavior.HoldEnd;
close.AutoReverse = false;
sb_close.Children.Add(close);
Storyboard.SetTarget(close, this);
Storyboard.SetTargetProperty(close, new PropertyPath("Opacity"));
} protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
if (!close_flg)
{
sb_close.Completed += delegate
{
close_flg = true;
this.Close();
};
sb_close.Begin();
e.Cancel = true;
}
else
{
e.Cancel = false;
}
} private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

直接用的话会运行不起来,主要看后台动画代码和逻辑

本文属原创 转载请写明出处

wpf 右下角弹出窗的更多相关文章

  1. DuiVision开发教程(18)-弹出窗

    DuiVision的弹出窗体类CDlgPopup,是菜单.下拉列表等控件的父类,也能够单独使用,用于创建弹出窗体.弹出窗体默认是非激活状态下自己主动关闭,比如鼠标点击到弹出窗体外面的区域,弹出窗体就会 ...

  2. Jquery和Javascript 实际项目中写法基础-弹出窗和弹出层 (4)

     一.实际项目中有很多如下界面效果.    二.该效果可以归结为弹出窗或者弹出层来实现的,为什么这么说?看如下代码:      <!DOCTYPE html> <html> & ...

  3. Bootstrap模态弹出窗

    Bootstrap模态弹出窗有三种方式: 1.href触发模态弹出窗元素: <a class="btn btn-primary" data-toggle="moda ...

  4. jquery Mobile弹出窗

    先创建一个窗体 <div data-role="popup" id="popupView" class="ui-content" da ...

  5. 右下角弹出"Windows-延缓写入失败"或者"xxx-损坏文件 请运行Chkdsk工具"

    知识点分析: 任务栏右下角弹出“Windows-延缓写入失败”或者“xxx-损坏文件 请运行Chkdsk工具”. 操作步骤: 方法一:Chkdsk工具 在开始---运行中输入cmd,然后输入chkds ...

  6. iOS:模态弹出窗控制器UIPopoverPresentationController

    模态弹出窗控制器:UIPopoverPresentationController 实质:就是将内容控制器包装成PopoverPresentationController的形式,然后再模态出来,必须指定 ...

  7. iOS:弹出窗控制器:UIPopoverController

    弹出窗控制器:UIPopoverController 截图:   实质:就是将内容控制器包装成popoverController的形式,然后在模态出来,必须给定指向目标(target.frame). ...

  8. C#利用API制作类似QQ一样的右下角弹出窗体

    C#利用API制作类似QQ一样的右下角弹出窗体 (2009-03-21 15:02:49) 转载▼ 标签: 杂谈 分类: .NET using System;using System.Collecti ...

  9. winform C#屏幕右下角弹出消息框并自动消失

    ①弹出信息框后慢慢下降消失 在主窗体中新增按钮重命名为btnShowAndDisappearMessages,在click事件中写如下代码: private void btnShowAndDisapp ...

随机推荐

  1. TIME_WAIT状态的作用

    TIME_WAIT状态: 主动关闭的那端最后经历的状态,一般为2MSL秒(1~4分钟). 两个原因: 保证当最后一个ack丢失后,能收到对端重传的fin包. 保证ack包消失,不会影响下一个连接. 关 ...

  2. 【校招面试 之 C/C++】第27题 C++ 智能指针(三)之 unique_ptr

    auto_ptr<string> p1(new string ("auto") : //#1 auto_ptr<string> p2; //#2 p2 = ...

  3. JAVA知识积累 给HttpClient添加Socks代理

    本文描述http client使用socks代理过程中需要注意的几个方面:1,socks5支持用户密码授权:2,支持https:3,支持让代理服务器解析DNS: 使用代理创建Socket 从原理上来看 ...

  4. 300最长上升子序列 · Longest Increasing Subsequence

    [抄题]: 往上走台阶 最长上升子序列问题是在一个无序的给定序列中找到一个尽可能长的由低到高排列的子序列,这种子序列不一定是连续的或者唯一的. 样例 给出 [5,4,1,2,3],LIS 是 [1,2 ...

  5. JSF控件的immediate属性和页面生命周期

    JSF中的控件基本都有immediate属性,对于这个属性的使用总结如下,更详细内容可参考Oracle官方文档. 1,为了更好的理解immediate属性,先看一下JSF页面的生命周期: JSF页面的 ...

  6. 用Vue-cli生成vue+webpack的项目模板怎么设置为vue1.0版本?

    用Vue-cli生成vue+webpack的项目模板 $ npm install -g vue-cli $ vue init webpack my-project $ cd my-project $ ...

  7. mysql 导入导出摘要

    1.导入by数据文件. mysql>load data infile '文件路径' into table 表名 fields terminated by '字段分隔符' lines termin ...

  8. redis学习-有序集合(zset)常用命令

    zadd:有序集合增加一个或者多个键值对 与set集合不同,zset添加的时候需要 指定 score,这个是用来排名的 zrange:返回指定范围的键 zcount:返回集合指定范围的个数(以每个键值 ...

  9. hadoop学习笔记(二):centos7三节点安装hadoop2.7.0

    环境win7+vamvare10+centos7 一.新建三台centos7 64位的虚拟机 master node1 node2 二.关闭三台虚拟机的防火墙,在每台虚拟机里面执行: systemct ...

  10. stark 增删改

    优雅装饰器 import functools def wrapper(func): @functools.wraps(func) # 保留原函数的信息 def inner(*args, **kwarg ...