当前位置: 首页 > news >正文

silverlight 做一个QQ式的消息提示窗

消息提示窗英文名叫Toastnotifications,Toast是吐司的意思,就是烤面包片

起初看到这个名字挺费解,这跟吐司有什么关系,后来终于明白,老外烤吐司的时候是这么做的,把很多面包片放进吐司机里,就是专门烤吐司的面包机,待烤好以后,吐司机会把面包弹起来,此时就是弹出的提示窗口一样,这种比喻很形像

下面进入正题,直接上代码

MainPage xaml部分

<UserControl x:Class="NotifyApplication.MainPage" 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" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <Grid x:Name="LayoutRoot" Background="White"> <Button Height="30" Width="200" Content="Display Notify Window" Click="Button_Click"/> </Grid> </UserControl>

code部分主要是一个用来调出提示框的按钮

using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace NotifyApplication { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { if(App.Current.IsRunningOutOfBrowser) { var notify = new NotificationWindow(); var win = new NotifyWindow { Header = {Text = "Custom Message Header"}, Description = {Text = "This is a custom description."} }; notify.Width = win.Width; notify.Height = win.Height; notify.Content = win; notify.Show(5000); } } } }

提示框是一个用户控件

<UserControl x:Class="NotifyApplication.NotifyWindow" 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" mc:Ignorable="d" Height="75" Width="300"> <Grid x:Name="LayoutRoot" Background="White"> <Border Background="#DDDDDD" BorderBrush="Black" BorderThickness="2"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="0.113*"/> <RowDefinition Height="0.306*"/> <RowDefinition Height="0.582*"/> </Grid.RowDefinitions> <Rectangle Fill="#FF747474" Stroke="White" StrokeThickness="0" Grid.ColumnSpan="2"/> <TextBlock TextWrapping="Wrap" Text="x" HorizontalAlignment="Right" Margin="0,0,5,0" Grid.Row="1" FontFamily="Verdana" FontWeight="Bold" FontSize="13"/> <TextBlock Name="Header" TextWrapping="Wrap" Text="Header Text" Grid.Row="1" FontWeight="Bold" VerticalAlignment="Bottom" FontSize="13" Margin="5,0,5,0" FontFamily="Tahoma"/> <TextBlock Name="Description" TextWrapping="Wrap" Text="Notification Text" Grid.Row="2" FontSize="11" FontFamily="Verdana" Margin="5,0,5,0"/> </Grid> </Border> </Grid> </UserControl>

用这里还没完,要设置成可在浏览器外运行

右键点silverlight 项目-->silverlight 标签页 -->Enable running application out of the browser 打上勾

相关文章:

  • .NET 分布式技术比较
  • silverlight调用exe程序
  • JS 获取页面html信息
  • 悟系统规则
  • solr自动提示 - jquery ui autocomplete
  • SQL SERVER中查找某个字段位于哪些表
  • cdoj 847 方老师与栈 火车进出战问题
  • OpenGL绘制简单的时钟(首发测试)
  • VMware workstation 6.5安装Red Hat Linux 9
  • great C++ socket library
  • Android手机分辨率基础知识(DPI,DIP计算)
  • WebApi2官网学习记录---单元测试
  • redhat9 内核由2.4.20-8至2.6.10全过程
  • stdarg.h详解
  • C# 6.0 的那些事
  • 《Java8实战》-第四章读书笔记(引入流Stream)
  • Hexo+码云+git快速搭建免费的静态Blog
  • Iterator 和 for...of 循环
  • Java 23种设计模式 之单例模式 7种实现方式
  • JavaWeb(学习笔记二)
  • mockjs让前端开发独立于后端
  • overflow: hidden IE7无效
  • XForms - 更强大的Form
  • 当SetTimeout遇到了字符串
  • 得到一个数组中任意X个元素的所有组合 即C(n,m)
  • 第三十一到第三十三天:我是精明的小卖家(一)
  • 我的面试准备过程--容器(更新中)
  • 用Visual Studio开发以太坊智能合约
  • 在 Chrome DevTools 中调试 JavaScript 入门
  • 3月7日云栖精选夜读 | RSA 2019安全大会:企业资产管理成行业新风向标,云上安全占绝对优势 ...
  • Redis4.x新特性 -- 萌萌的MEMORY DOCTOR
  • 我们雇佣了一只大猴子...
  • #NOIP 2014#Day.2 T3 解方程
  • #设计模式#4.6 Flyweight(享元) 对象结构型模式
  • (+3)1.3敏捷宣言与敏捷过程的特点
  • (C#)Windows Shell 外壳编程系列4 - 上下文菜单(iContextMenu)(二)嵌入菜单和执行命令...
  • (C#)获取字符编码的类
  • (DFS + 剪枝)【洛谷P1731】 [NOI1999] 生日蛋糕
  • (libusb) usb口自动刷新
  • (SpringBoot)第二章:Spring创建和使用
  • (定时器/计数器)中断系统(详解与使用)
  • (二)【Jmeter】专栏实战项目靶场drupal部署
  • (附源码)springboot 房产中介系统 毕业设计 312341
  • (十)c52学习之旅-定时器实验
  • (五)网络优化与超参数选择--九五小庞
  • (源码版)2024美国大学生数学建模E题财产保险的可持续模型详解思路+具体代码季节性时序预测SARIMA天气预测建模
  • (转)linux 命令大全
  • .NET Core 中的路径问题
  • .Net 中Partitioner static与dynamic的性能对比
  • .NET/ASP.NETMVC 深入剖析 Model元数据、HtmlHelper、自定义模板、模板的装饰者模式(二)...
  • .NET精简框架的“无法找到资源程序集”异常释疑
  • .Net面试题4
  • .net下简单快捷的数值高低位切换
  • /*在DataTable中更新、删除数据*/
  • ?.的用法