从长商议Silverlight(44) – 4.0浏览器外运行葡京在线开户(Out Of Browser)之OOB的增加及其新增的NotificationWindow

            Button btnClose = new Button();
            btnClose.Content = “关闭”;
            btnClose.Click += (x, y) => { popup.IsOpen = false; };

  • ChildWindow – 用于在父窗体前弹出3个的子窗体
  • SaveFileDialog – 用户发起的保存文件对话框(OpenFileDialog –
    打开文件对话框)
  • HeaderedItemsControl – 展现标题和汇集数据的控件
  • VirtualizingStackPanel – 虚拟化的 StackPanel(即仅生成供给浮现的 UI
    成分。当绑定了大气数目,而某时仅浮现中间一小部分的时候,使用此控件则可小幅度进步呈现功用) 

namespace Silverlight40.OutOfBrowser
{
    public partial class AutoUpdateDemo : Page
    {
        public AutoUpdateDemo()
        {
            InitializeComponent();
        }

2、从长商议Silverlight(34) – 3.0控件之Frame, Page, Label,
DescriptionViewer,
ValidationSummary

介绍
Silverlight 3.0 控件一览:

            popup.Child = border;

  • GPU 加快 – 对 GPU 加快的支撑
  • Out-Of-Browser –  浏览器外运维,即帮助脱离浏览器运转
  • 使用程序库缓存 – 将 dll(zip) 缓存到客户端浏览器中 
  • 联合 ResourceDictionary – 整合分化职位的 ResourceDictionary 
  • 应用程序增添服务 – 通过扩大 Application 来提供附加服务
  • Silverlight 插件对象的新增效益 – 在 Silverlight 3.0 中 Silverlight
    插件对象的新增效益

        </StackPanel>
    </Grid>
</navigation:Page>

9、从长计议Silverlight(41) – 3.0Tip/Trick之GPU 加速, Out-Of-Browser,
应用程序库缓存, 合并 ResourceDictionary, 应用程序扩张服务, Silverlight
插件对象

介绍
Silverlight 3.0 提醒和技艺连串

            // 将 NotificationWindow 的显得内容设置为自定义的始末
            CustomNotificationWindow custom = new CustomNotificationWindow();
            custom.Title = “我是标题”;
            custom.Text = “小编是内容”;
            custom.Width = notify.Width;
            custom.Height = notify.Height;
            custom.Closed += (x, y) => { notify.Close(); };

[源码下载]

在线DEMO
http://www.cnblogs.com/webabcd/archive/2010/08/09/1795417.html

6、从长计议Silverlight(38) – 3.0滤镜之BlurEffect, DropShadowEffect,
自定义滤镜, 3D效果之PlaneProjection,
位图API之WriteableBitmap

介绍
Silverlight 3.0 图形系统的相干新增功用

namespace Silverlight40.OutOfBrowser
{
    public class CustomNotificationWindow : ContentControl
    {
        public CustomNotificationWindow()
        {
            // 设置控件的暗中同意样式
            this.DefaultStyleKey = typeof(CustomNotificationWindow);
        }

  • TreeView – 树控件
  • ListBox – 立异:援救多选
  • DataGrid – 立异:结合 PagedCollectionView 完成数据分组,
    伸张了部分编辑数据的相关事件, 结合 DataAnnotations 已毕多少印证,
    等。。。
  • MediaElement – 增加了对视频 H.264 编码格式的支撑,和对旋律 AAC
    编码格式的协助 

            <Button Name=”btnOutOfBrowser” Margin=”50″ Click=”btnOutOfBrowser_Click” />

在线DEMO
http://www.cnblogs.com/webabcd/archive/2009/08/04/1538238.html

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            if (Application.Current.IsRunningOutOfBrowser)
                Application.Current.MainWindow.Close();
        }
    }
}

OK
[源码下载]

作者:webabcd

事缓则圆 Silverlight 3.0 种类小说索引

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (App.Current.IsRunningOutOfBrowser)
                btnOutOfBrowser.Content = “卸载”;
            else
                btnOutOfBrowser.Content = “安装”;

  • AutoCompleteBox – 自动已毕控件。当用户输入部分信息后,此控件可以根据钦定的过滤算法在两个下拉框中列支出匹配项
  • DataPager – 分页控件 

            }
            else
            {
                if (e.IsCancelable)
                    e.Cancel = true;
            }
        }

作者:webabcd

葡京在线开户 1葡京在线开户 2代码

  • Frame – 与 Page 控件结合使用,从而落成导航作用(可以通过完结 Deep
    Linking)
  • Page – 与 Frame 控件结合使用
  • Label – 比 TextBlock 功能多一些,可以用来对错误的求证音信做指示
  • DescriptionViewer – 鼠标经过时的提醒音信 
  • ValidationSummary – 汇总显示验证错误的音信 

            Border border = new Border();
            border.BorderBrush = new SolidColorBrush(Colors.Black);
            border.BorderThickness = new Thickness(5.0);

  • Easing 可以与 Storyboard 结合贯彻动画的缓动效果
  • Silverlight 3 内置 11 种缓动效果:分别为BackEase, BounceEase,
    CircleEase, CubicEase, ElasticEase, ExponentialEase, PowerEase,
    QuadraticEase, QuarticEase, QuinticEase, SineEase
  • 依次缓动类都继承自 EasingFunctionBase,除了 EasingFunctionBase
    提供的成效外,各种缓动类可能还会有些的性质(懒的写了,查文档吧) 
  • EasingFunctionBase 有三个用来安装缓动格局的枚举类型属性 EasingMode
    (EasingMode.EaseOut(暗中同意值), EasingMode.EaseIn,
    EasingMode.EaseInOut)

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (App.Current.IsRunningOutOfBrowser)
                btnOutOfBrowser.Content = “卸载”;
            else
                btnOutOfBrowser.Content = “安装”;
        }

补充:
一 、UIElement 上新增了 MouseWheel 事件

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;
using System.Windows.Navigation;

7、事缓则圆Silverlight(39) – 3.0通讯之二进制XML通讯,
本地连接

介绍
Silverlight 3.0 通讯的新增效益

       
        private void btnShowPopup_Click(object sender, RoutedEventArgs e)
        {
            /*
             * Popup – 用于在 Silverlight 程序区域之内,Silverlight 内容之上显示内容,其通吃浏览器内外。来自 Silverlight 2.0
             *     Popup.Child – Popup 上出示的故事情节 
             *     Popup.IsOpen – 是不是出示 Popup
             */

8、三思而行Silverlight(40) – 3.0绑定之Element to Element Binding,
RelativeSource; 样式之动态修改样式, 样式继承,
自定义光标

介绍
Silverlight 3.0 绑定的新增效益,样式相关的新增效益

葡京在线开户 3葡京在线开户 4代码

5、三思而行Silverlight(37) –
3.0动画之Easing(缓动效果)

介绍
Silverlight 3.0 动画的缓动效果:

        private void Init()
        {
            lblMsg.Text = string.Format(“网络状态:{0}”, NetworkInterface.GetIsNetworkAvailable().ToString());

3、从长商议Silverlight(35) – 3.0控件之ChildWindow, SaveFileDialog,
HeaderedItemsControl,
VirtualizingStackPanel

介绍
Silverlight 3.0 控件一览:

AutoUpdateDemo.xaml.cs

1、多加商量Silverlight(33) – 3.0控件之AutoCompleteBox,
DataPager

介绍
Silverlight 3.0 控件一览:

葡京在线开户 5葡京在线开户 6代码

  • 二进制XML通讯 – 与 WCF 服务间通讯,可以应用二进制 XML
    传递数据(升高传输品质) 
  • 本地连接 – 允许客户端的四个 Silverlight
    程序之间一贯开展通信(不用通过服务端)

CustomNotificationWindowDemo.xaml.cs

  • BlurEffect – 模糊滤镜 
  • DropShadowEffect – 阴影滤镜
  • 自定义滤镜 
  • PlaneProjection – 将平面的 UIElement 映射到 3D
  • WriteableBitmap – 位图 API(Bitmap API)

        void Current_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
        {
            if (e.UpdateAvailable)
            {
                lblMsg.Text += “\n更新完成,请重启程序”;
            }
            else
            {
                if (e.Error == null)
                    lblMsg.Text += “\n程序无更新(倘若有新更新要修改 Assembly Version)”;
                else
                    lblMsg.Text += “\n” + e.Error.ToString();
            }
        }
    }
}

4、事缓则圆Silverlight(36) – 3.0控件之TreeView, ListBox增强,
DataGrid增强,
MediaElement增强

介绍
Silverlight 3.0 控件一览:

            <TextBlock Text=”OOB 情势的 toast(以及与 Popup 的比较)详见本目录下的 NotificationWindow德姆o.xaml” Margin=”5″ />

  • Element to Element Binding – Element 到 Element 之间的绑定 
  • RelativeSource – 贰个扩张标记,用于内定关联数据源为 Self 或
    TemplatedParent 
  • 动态修改样式 – 在 Runtime 时修改样式 
  • 体制继承 – 通过 BasedOn 使某样式可以一而再自另3个样式 
  • 自定义光标 – 通过 CaretBrush 自定义输入框的光标的样式 

Demo.xaml.cs

从长远的角度考虑Silverlight(44) – 4.0浏览器外运维(Out Of
Browser)之OOB的增高及其新增的NotificationWindow

using System.Windows.Controls.Primitives;

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (App.Current.IsRunningOutOfBrowser)
                btnOutOfBrowser.Content = “卸载”;
            else
                btnOutOfBrowser.Content = “安装”;
        }

            <TextBlock Text=”OOB 情势下自定义 NotificationWindow 的内容及体制详见本目录下的 CustomNotificationWindow德姆o.xaml” Margin=”5″ />

葡京在线开户 7葡京在线开户 8代码

            <!– 自定义 NotificationWindow 的 Demo –>
            <Button Name=”btnShowCustomNotificationWindow” Margin=”5″ Content=”弹出 CustomNotificationWindow” Click=”btnShowCustomNotificationWindow_Click” />

    <Style TargetType=”local:CustomNotificationWindow”>
        <Setter Property=”IsTabStop” Value=”False”/>
        <Setter Property=”Background” Value=”Black”/>
        <Setter Property=”Template”>
            <Setter.Value>
                <ControlTemplate TargetType=”local:CustomNotificationWindow”>
                    <StackPanel>
                        <!– 关闭按钮 –>
                        <Button Name=”btnClose” Content=”关闭” VerticalAlignment=”Top” HorizontalAlignment=”Right” Margin=”5″ />
                        <!– toast 的标题 –>
                        <TextBlock Text=”{TemplateBinding Title}” Foreground=”Red” FontWeight=”Bold” FontSize=”12″ />
                        <!– toast 的正文 –>
                        <TextBlock Text=”{TemplateBinding Text}” FontSize=”12″ TextWrapping=”Wrap” />
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>

<ResourceDictionary
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml
    xmlns:sys=”clr-namespace:System;assembly=mscorlib”
    xmlns:vsm=”clr-namespace:System.Windows;assembly=System.Windows”
    xmlns:local=”clr-namespace:Silverlight40.OutOfBrowser”>

CustomNotificationWindow.xaml

        private void btnShowCustomNotificationWindow_Click(object sender, RoutedEventArgs e)
        {
            // 实例化壹个 NotificationWindow,并点名其宽和高
            NotificationWindow notify = new NotificationWindow();
            notify.Width = 320;
            notify.Height = 80;

葡京在线开户 9葡京在线开户 10代码

            Popup popup = new Popup();

        //  UI 成分在应用程序中突显从前所调用的主意
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

        </StackPanel>
        
    </Grid>
</navigation:Page>

/*
 * 本例演示 Silverlight 应用程序在 OOB 方式下的自动更新
 * 注1:Silverlight 应用程序依照 Assembly Version 来判断是还是不是要求革新
 * 注2:程序下载成功后,须要重启 Silverlight 应用程序,那样运行的才是创新后的次序
 * 
 * NetworkInterface.GetIsNetworkAvailable() – 互连网是或不是管用
 * NetworkChange.NetworkAddressChanged – 网络状态爆发变化时所接触的轩然大波
 * Application.CheckAndDownloadUpdateAsync, Application.CheckAndDownloadUpdateCompleted – 一对异步方法/事件,用于更新浏览器外运维的 Silverlight 程序(从服务器上下载新的本子)
 * CheckAndDownloadUpdateCompleted伊夫ntArgs.UpdateAvailable – 是不是已经成功更新了本子
 * CheckAndDownloadUpdateCompleted伊芙ntArgs.Error – 下载更新时发出了拾贰分
 */

介绍
Silverlight 4.0 OOB 格局的新特性:

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (App.Current.IsRunningOutOfBrowser)
                btnOutOfBrowser.Content = “卸载”;
            else
                btnOutOfBrowser.Content = “安装”;
            
            Init();
        }

[索引页]
[源码下载]

            <Button Name=”btnClose” Margin=”50″ Content=”关闭” Click=”btnClose_Click” />

            <TextBlock Text=”OOB 格局下网络情状的检测,以及程序的升级换代详见本目录下的 AutoUpdate德姆o.xaml” Margin=”5″ />

                TextBlock lblMsg = new TextBlock();
                lblMsg.Text = “NotificationWindow 信息”;
                lblMsg.FontSize = 18;

葡京在线开户 11葡京在线开户 12代码

        private void btnOutOfBrowser_Click(object sender, RoutedEventArgs e)
        {
            if (!App.Current.IsRunningOutOfBrowser && App.Current.InstallState == InstallState.NotInstalled)
                App.Current.Install();
            else
                MessageBox.Show(“已经安装,使用右键卸载”);
        }

/*
 * NotificationWindow – 在 OOB 方式下显得公告窗口,相当于 toast
 */

                notify.Content = lblMsg;

            if (App.Current.IsRunningOutOfBrowser && NetworkInterface.GetIsNetworkAvailable())
            {
                App.Current.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted);
                App.Current.CheckAndDownloadUpdateAsync();

                notify.Show(3000);
            }
            else
            {
                Message博克斯.Show(“请在浏览器外运转”);
            }
        }
    }
}

NotificationWindowDemo.xaml.cs

    <ResourceDictionary.MergedDictionaries>
        <!–
            自定义控件时,将 Style 放到 generic.xaml 之外的注意事项:generic.xaml 和 Style 的 xaml 文件均要安装为能源类型
        –>
        <ResourceDictionary Source=”/Silverlight40;component/themes/CustomNotificationWindow.xaml”/>
    </ResourceDictionary.MergedDictionaries>

            popup.IsOpen = true;
        }
       
        private void btnShowNotificationWindow_Click(object sender, RoutedEventArgs e)
        {
            /*
             * NotificationWindow.Content – toast 所出示的始末
             * NotificationWindow.Show(int durationInMilliseconds) – 突显 toast,并在内定时间后隐藏 toast
             * 
             * 注:各种 Silverlight 应用程序在同暂且间只可以展现贰个 toast 。假若在1个 toast 正在突显的同时调用 NotificationWindow.Show() 则会引发那么些
             */

            notify.Content = custom;

            StackPanel container = new StackPanel();
            container.Width = 320;
            container.Height = 240;
            container.Background = new SolidColorBrush(Colors.Yellow);

namespace Silverlight40.OutOfBrowser
{
    public partial class NotificationWindowDemo : Page
    {
        public NotificationWindowDemo()
        {
            InitializeComponent();
        }

/*
 * 本例用于演示 Closing 事件
 * Application.Current.MainWindow – OOB 情势下的应用程序窗口。属性值为 System.Windows.Window 类型
 * Window.Activate() – 激活窗口,使之富有典型,并内置最前面
 * Window.IsActive – 是还是不是为激活窗口(仅 get)
 * Window.Close() – 关闭窗口
 * Window.Closing – 窗口关闭前触发的事件。事件参数为 System.ComponentModel.Closing伊夫ntArgs 类型
 *     Closing伊夫ntArgs.IsCancelable – 是不是足以收回窗口的关门事件
 *     Closing伊夫ntArgs.Cancel – 是或不是吊销窗口的关闭事件
 */

/*
 * 本例演示怎么着兑现自定的 NotificationWindow
 */

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;
using System.Windows.Navigation;

namespace Silverlight40.OutOfBrowser
{
    public partial class CustomNotificationWindowDemo : Page
    {
        public CustomNotificationWindowDemo()
        {
            InitializeComponent();
        }

            <!– Popup 的 Demo –>
            <Button Name=”btnShowPopup” Margin=”5″ Content=”弹出 Popup” Click=”btnShowPopup_Click” />

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;
using System.Windows.Navigation;

<ResourceDictionary
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml
    xmlns:sys=”clr-namespace:System;assembly=mscorlib”
    xmlns:vsm=”clr-namespace:System.Windows;assembly=System.Windows”
    xmlns:local=”clr-namespace:Silverlight40.OutOfBrowser”>

④ 、演示怎么样落到实处自定义的 NotificationWindow
generic.xaml

        private void btnOutOfBrowser_Click(object sender, RoutedEventArgs e)
        {
            if (!App.Current.IsRunningOutOfBrowser && App.Current.InstallState == InstallState.NotInstalled)
                App.Current.Install();
            else
                MessageBox.Show(“已经设置,使用右键卸载”);
        }

        <StackPanel HorizontalAlignment=”Left”>

/*
 * 本例演示如何接纳自定的 NotificationWindow
 */

        // toast 的正文
        public string Text
        {
            get { return (string)GetValue(CustomNotificationWindow.TextProperty); }
            set { SetValue(CustomNotificationWindow.TextProperty, value); }
        }
        public static readonly DependencyProperty TextProperty = DependencyProperty.Register
        (
            “Text”,
            typeof(string),
            typeof(CustomNotificationWindow),
            new PropertyMetadata(OnTextPropertyChanged)
        );
        private static void OnTextPropertyChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
        {
        }

<navigation:Page x:Class=”Silverlight40.OutOfBrowser.AutoUpdateDemo” 
           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:navigation=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation”
           Title=”AutoUpdateDemo Page”>
    <Grid x:Name=”LayoutRoot”>
        <StackPanel>
            
            <Button Name=”btnOutOfBrowser” Margin=”50″ Click=”btnOutOfBrowser_Click” />
            
            <TextBlock Name=”lblMsg” />
            
        </StackPanel>
    </Grid>
</navigation:Page>

namespace Silverlight40.OutOfBrowser
{
    public partial class Demo : Page
    {
        public Demo()
        {
            InitializeComponent();
        }

            popup.VerticalOffset = 100;
            popup.HorizontalOffset = 100;

<navigation:Page x:Class=”Silverlight40.OutOfBrowser.NotificationWindowDemo” 
           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:navigation=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation”
           Title=”NotificationWindowDemo Page”>
    <Grid x:Name=”LayoutRoot”>
        <StackPanel HorizontalAlignment=”Left”>
            <Button Name=”btnOutOfBrowser” Margin=”50″ Click=”btnOutOfBrowser_Click” />

            <!– NotificationWindow 的 Demo –>
            <Button Name=”btnShowNotificationWindow” Margin=”5″ Content=”弹出 NotificationWindow” Click=”btnShowNotificationWindow_Click” />

葡京在线开户 13葡京在线开户 14代码

三 、演示 NotificationWindow(toast) 的效用,以及其和 Popup 的相持统一
NotificationWindowDemo.xaml

OK
[源码下载]

  • 新增了 Closing 事件
  • 兑现程序在 OOB 形式下的自动更新
  • NotificationWindow – 在 OOB 格局下显得通告窗口,相当于 toast
  • 贯彻自定义的 NotificationWindow

        public event EventHandler<EventArgs> Closed;
    }
}

葡京在线开户 15葡京在线开户 16代码

            // 网络状态发生转移时所接触的事件,能够拔网线看效率
            NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);

/*
 * 调试 OOB 格局下的 Silverlight 程序:启用 OOB 形式,将 Silverlight 项目设置为运维项目,然后运转即可
 */

CustomNotificationWindow.cs

示例
① 、OOB(Out Of Browser)情势的复习,以及其新增的 Closing 事件
Demo.xaml

            TextBlock lblMsg = new TextBlock();
            lblMsg.Text = “Popup 信息”;

            if (App.Current.IsRunningOutOfBrowser)
            {
                NotificationWindow notify = new NotificationWindow();
                notify.Width = 320;
                notify.Height = 80;

        void MainWindow_Closing(object sender, System.ComponentModel.ClosingEventArgs e)
        {
            if (MessageBox.Show(“确认关闭呢?”, “确认”, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {

二 、演示如何落实程序在 OOB 格局下的自动更新
AutoUpdateDemo.xaml

        // toast 的标题
        public string Title
        {
            get { return (string)GetValue(CustomNotificationWindow.TitleProperty); }
            set { SetValue(CustomNotificationWindow.TitleProperty, value); }
        }
        public static readonly DependencyProperty TitleProperty = DependencyProperty.Register
        (
            “Title”,
            typeof(string),
            typeof(CustomNotificationWindow),
            new PropertyMetadata(OnTitlePropertyChanged)
        );
        private static void OnTitlePropertyChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
        {
        }

                lblMsg.Text += “\n检查更新。。。”;
            }
        }

CustomNotificationWindowDemo.xaml

        private void btnOutOfBrowser_Click(object sender, RoutedEventArgs e)
        {
            if (!App.Current.IsRunningOutOfBrowser && App.Current.InstallState == InstallState.NotInstalled)
                App.Current.Install();
            else
                MessageBox.Show(“已经设置,使用右键卸载”);
        }

            Init();
        }

using System.Net.NetworkInformation;

葡京在线开户 17葡京在线开户 18代码

<navigation:Page x:Class=”Silverlight40.OutOfBrowser.CustomNotificationWindowDemo” 
           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:navigation=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation”
           Title=”CustomNotificationWindowDemo Page”>
    <Grid x:Name=”LayoutRoot”>
        <StackPanel HorizontalAlignment=”Left”>
            <Button Name=”btnOutOfBrowser” Margin=”50″ Click=”btnOutOfBrowser_Click” />

            // Control.GetTemplateChild() – 在实例化的 ControlTemplate 可视化树中检索已命名的因素
            Button btnClose = GetTemplateChild(“btnClose”) as Button;
            if (btnClose != null)
            {
                btnClose.Click += (s, e) =>
                {
                    EventHandler<EventArgs> handler = this.Closed;
                    if (handler != null)
                        handler(this, EventArgs.Empty);
                };
            }
        }

<navigation:Page x:Class=”Silverlight40.OutOfBrowser.Demo” 
           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:navigation=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation”
           Title=”Other Page”>
    <Grid x:Name=”LayoutRoot”>

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

        private void btnOutOfBrowser_Click(object sender, RoutedEventArgs e)
        {
            if (!App.Current.IsRunningOutOfBrowser && App.Current.InstallState == InstallState.NotInstalled)
                App.Current.Install();
            else
                MessageBox.Show(“已经设置,使用右键卸载”);
        }

        </StackPanel>
    </Grid>
</navigation:Page>

            notify.Show(3000);
        }
    }
}

        void Init()
        {
            if (Application.Current.IsRunningOutOfBrowser)
                Application.Current.MainWindow.Closing += new EventHandler<System.ComponentModel.ClosingEventArgs>(MainWindow_Closing);
        }

</ResourceDictionary>

        void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
        {
            lblMsg.Text += “\n”;
            lblMsg.Text += string.Format(“网络状态:{0}”, NetworkInterface.GetIsNetworkAvailable().ToString());
        }

葡京在线开户 19葡京在线开户 20代码

/*
 * Silverlight 3.0 时期全体如下特征
 * Application.InstallStateChanged – 浏览器外运作的有关情形爆发变更时所接触的事件
 * Application.InstallState – 浏览器外运行的相干景况 [System.Windows.InstallState 枚举]
 *     NotInstalled – 在浏览器中运作
 *     Installing – 安装到桌面中
 *     Installed – 在浏览器外运维
 *     InstallFailed – 安装到桌面的长河中发出错误
 * Application.IsRunningOutOfBrowser – 当前程序是或不是是从浏览器外运营的
 * Application.Install() – 安装 Silverlight 程序到浏览器外(卸载只能通过右键菜单的办法卸载)
 * Application.CheckAndDownloadUpdateAsync, Application.CheckAndDownloadUpdateCompleted – 一对异步方法/事件,用于立异浏览器外运营的 Silverlight 程序(从服务器上下载新的本子)
 * 
 * 启用 OOB:在 Silverlight 项目上单击右键 -> 属性 -> Silverlight -> 选中 Enable running application out of the browser
 * 配置 OOB:在 Silverlight 项目上单击右键 -> 属性 -> Silverlight -> Out-of-Browser Settings 可以对“浏览器外运营”的连锁参数做设置(也得以手动修改 Properties/OutOfBrowserSettings.xml)
 */

            container.Children.Add(lblMsg);
            container.Children.Add(btnClose);
            border.Child = container;

葡京在线开户 21葡京在线开户 22代码

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;
using System.Windows.Navigation;