silverlight 判断窗口打开

silverlight 判断窗口打开,第1张

概述  编辑NotificationControl控件,我们简单的对该控件进行美化,使其看起来更加友好,    1  < UserControl  x:Class ="SilverlightOOBDemo.NotificationControl"  2      xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  3   

编辑NotificationControl控件,我们简单的对该控件进行美化,使其看起来更加友好,

 

 1  < UserControl  x:Class ="SilverlightOOBDemo.NotificationControl"
 2      xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 3      xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
 4      xmlns:d ="http://schemas.microsoft.com/Expression/blend/2008"
 5      xmlns:mc ="http://schemas.openxmlformats.org/markup-compatibility/2006"
 6      mc:Ignorable ="d"
 7      d:DesignHeight ="300"  d:DesignWIDth ="400" >
 8      
 9       < GrID  x:name ="LayoutRoot"  Background ="White" >
10           < border  x:name ="Frame"  WIDth ="300"  Height ="100"  Background ="lightYellow" >
11               < StackPanel  OrIEntation ="Vertical" >
12                   < border  WIDth ="290"  Height ="24"  CornerRadius ="4"  margin ="2,4,2,4" >
13                       < border.Background >
14                           < linearGradIEntBrush  StartPoint ="0.5,0.0"
15                          EndPoint ="0.5,1.0" >
16                               < GradIEntStop  Offset ="0.2"  color ="#FF1C68A0"   />
17                               < GradIEntStop  Offset ="1.0"  color ="#FF54A7E2"   />
18                           </ linearGradIEntBrush >
19                       </ border.Background >
20                       < border.Effect >
21                           < DropShadowEffect  BlurRadius ="4"  ShadowDepth ="4"
22                          Opacity ="0.4"   />
23                       </ border.Effect >
24                       < TextBlock  Text ="友情提示"  FontSize ="12"
25                      FontWeight ="Bold"  Foreground ="White"  margin ="4"   />
26                   </ border >
27                   < StackPanel  OrIEntation ="Horizontal" >
28                       < Image  Source ="/SilverlightOOBDemo;component/Images/Update.png"  WIDth ="48"  Height ="48"
29                      Stretch ="Fill"  margin ="4"  VerticalAlignment ="top"   />
30                       < TextBlock  WIDth ="240"  Text ="检测到新的音乐文件,已经更新到播放列表。小广告:我的博客http://jv9.cnblogs.com"
31                      FontSize ="11"  Foreground ="#FF202020"  textwrapPing ="Wrap"
32                      margin ="4"   />
33                   </ StackPanel >
34               </ StackPanel >
35           </ border >
36       </ GrID >
37  </ UserControl >
38 

 

 

然后回到OutofbrowserMainPage页面,这里,我们在“关于”按钮上,添加Click事件响应,使其被点击后,d出Notifications窗口

 

首先创建notifyWindow实例,

 

 1  #region  Private Members
 2          Window OOBWindow  =  Application.Current.MainWindow;
 3          NotificationWindow notifyWindow  =   null ;
 4           #endregion
 5 
 6           #region  Constructor
 7           public  OutofbrowserMainPage()
 8          {
 9              InitializeComponent();
10              notifyWindow  =   new  NotificationWindow();
11             
12            
13          }
14  #endregion

 

 

然后在Click事件中进行窗口激活:

 1           private   voID  aboutBtn_Click( object  sender, RoutedEventArgs e)
 2          {
 3               if  ( null   ==  notifyWindow)
 4                  MessageBox.Show( " 通告窗口仅能运行在OOB模式下,请安装Silverlight应用到本地。 " );
 5 
 6               if  ( true   ==  App.Current.IsRunningOutOfbrowser)
 7              {
 8                   if  (notifyWindow.Visibility  ==  Visibility.Visible)
 9                      notifyWindow.Close();
10 
11                  NotificationControl myNotify  =   new  NotificationControl();
12                  notifyWindow.WIDth  =   300 ;
13                  notifyWindow.Height  =   100 ;
14                  notifyWindow.Content  =  myNotify;
15                  notifyWindow.Show( 10000 );
16              }
17                
18          }

 

 

在上面代码中,我们创建了一个新的Notification窗口实例,然后使用Show(毫秒),使其显示在客户端,最终显示效果如下:

 

 

今天的内容暂时到这里了,下一篇,我们将综合使用这些Silverlight OOB应用开发技巧实现一个完整应用实例, Silverlight Out of browser音乐播放器。

 

本篇源代码下载

总结

以上是内存溢出为你收集整理的silverlight 判断窗口打开全部内容,希望文章能够帮你解决silverlight 判断窗口打开所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1073791.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存