wpf 右下角弹出窗
自己写的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 右下角弹出窗的更多相关文章
- DuiVision开发教程(18)-弹出窗
DuiVision的弹出窗体类CDlgPopup,是菜单.下拉列表等控件的父类,也能够单独使用,用于创建弹出窗体.弹出窗体默认是非激活状态下自己主动关闭,比如鼠标点击到弹出窗体外面的区域,弹出窗体就会 ...
- Jquery和Javascript 实际项目中写法基础-弹出窗和弹出层 (4)
一.实际项目中有很多如下界面效果. 二.该效果可以归结为弹出窗或者弹出层来实现的,为什么这么说?看如下代码: <!DOCTYPE html> <html> & ...
- Bootstrap模态弹出窗
Bootstrap模态弹出窗有三种方式: 1.href触发模态弹出窗元素: <a class="btn btn-primary" data-toggle="moda ...
- jquery Mobile弹出窗
先创建一个窗体 <div data-role="popup" id="popupView" class="ui-content" da ...
- 右下角弹出"Windows-延缓写入失败"或者"xxx-损坏文件 请运行Chkdsk工具"
知识点分析: 任务栏右下角弹出“Windows-延缓写入失败”或者“xxx-损坏文件 请运行Chkdsk工具”. 操作步骤: 方法一:Chkdsk工具 在开始---运行中输入cmd,然后输入chkds ...
- iOS:模态弹出窗控制器UIPopoverPresentationController
模态弹出窗控制器:UIPopoverPresentationController 实质:就是将内容控制器包装成PopoverPresentationController的形式,然后再模态出来,必须指定 ...
- iOS:弹出窗控制器:UIPopoverController
弹出窗控制器:UIPopoverController 截图: 实质:就是将内容控制器包装成popoverController的形式,然后在模态出来,必须给定指向目标(target.frame). ...
- C#利用API制作类似QQ一样的右下角弹出窗体
C#利用API制作类似QQ一样的右下角弹出窗体 (2009-03-21 15:02:49) 转载▼ 标签: 杂谈 分类: .NET using System;using System.Collecti ...
- winform C#屏幕右下角弹出消息框并自动消失
①弹出信息框后慢慢下降消失 在主窗体中新增按钮重命名为btnShowAndDisappearMessages,在click事件中写如下代码: private void btnShowAndDisapp ...
随机推荐
- ASP.NET中修改从数据库获取的datatable中的值
有些时候,我们从数据库表中获取一个实体的对象,但有些内容并不是最终显示的内容,格式也都是不一样.经过一番尝试,发现datatable中的数值如果跟想要改变的类型不一致,就无法更改,只有添加新列,然后把 ...
- css学习-css引入&css选择
一.引入css的方式,一共有4种,我们只需要掌握三种就可以了,@import的方法我们不做掌握 1.第一种引入的方法 <!--1.第一种引入css的方法--> <h1 style=& ...
- Spring_AOP动态代理详解(转)
在学习Spring的时候,我们知道Spring主要有两大思想,一个是IoC,另一个就是AOP,对于IoC,依赖注入就不用多说了,而对于Spring的核心AOP来说,我们不但要知道怎么通过AOP来满足的 ...
- java 错误: 找不到或无法加载主类
这个问题应该很常见的,笔者经常手工编译一些测试代码或者小工具,经常用到 javac和java来编译并运行一些简单的小工具. 以Hello World来测试. HelloWorld.java publi ...
- 源代码安装grub-customizer
wget https://launchpad.net/grub-customizer/5.0/5.0.6/+download/grub-customizer_5.0.6.tar.gztar zxvf ...
- PowerDesigner :
P:是否为主键: F:是否为外键: M:表示强制非空: D:是否在模型中显示 修改样式.字体.颜色.等:Tools->Display Preferences->Format-> Po ...
- PS想象的力量无限大,设计师的脑洞无限大!
我(nemanjasekulic)一直对魔法与科幻感兴趣,但是,现实中,它们并不存在.我所做的是尽量体现一切都是可能的,表达一种没有约束的理想概念. 编辑:千锋UI设计
- Eloquent Observer 的小坑
前言 最近开发新的项目不是基于完整的 laravel 框架,框架是基于 laravel ORM 的简单MVC模式.随着项目的成熟和业务需求,需要引入事件机制.简单地浏览了一下 symfony.lara ...
- Autotest Weekly Report
Autotest Weekly Report Reported by: 12/16/2013 What I Did Last Week Debug autotest scripts of ‘smart ...
- Spring.NET学习笔记8——集合类型的注入(基础篇)
1.基础类 public class Happy { public override string ToString() { return &q ...