在Silverlight4中新增加了NotificationWindow特性,用来在windows右下角出现一个提示窗口。这两天刚好做项目的时候用到,就顺便写上来一个简单的Demo。
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
TextBlock tb
=
new
TextBlock
{
Text = " Hello World " ,
Foreground = new SolidColorBrush(Colors.Red)
};
NotificationWindow notifyWindow = new NotificationWindow
{
Width = 329 ,
Height = 74 ,
Content = tb
};
notifyWindow.Show( 3000 );
{
Text = " Hello World " ,
Foreground = new SolidColorBrush(Colors.Red)
};
NotificationWindow notifyWindow = new NotificationWindow
{
Width = 329 ,
Height = 74 ,
Content = tb
};
notifyWindow.Show( 3000 );
效果:
首先初始化一个NotificationWindow并指定它的宽和高,然后用content属性来指定窗口里边现实的内容,这里指定显示的内容为前边声明的TextBlock。用show方法显示出来,show的参数代表NotificationWindow停留的时间,以毫秒为单位。
需要注意下NotifycationWindow只能在OOB下使用。