葡京在线开户稳扎稳打 Silverlight 3.0 系列文章索引

            Init();
        }

  • Frame – 与 Page 控件结合使用,从而实现导航功能(可以通过实现 Deep
    Linking)
  • Page – 与 Frame 控件结合使用
  • Label – 比 TextBlock 功能多片,可以就此来对错的征信息做提示
  • DescriptionViewer – 鼠标经过时之提示信息 
  • ValidationSummary – 汇总显示验证错误的信息 

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

8、稳扎稳打Silverlight(40) – 3.0绑定之Element to Element Binding,
RelativeSource; 样式之动态修改样式, 样式继承,
自定义光标
介绍
Silverlight 3.0 绑定的初添效益,样式相关的新增加效益

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

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

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;

2、稳扎稳打Silverlight(34) – 3.0控件之Frame, Page, Label,
DescriptionViewer,
ValidationSummary
介绍
Silverlight 3.0 控件一见到:

        // 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)
        {
        }

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(); };

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

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

1、稳扎稳打Silverlight(33) – 3.0控件之AutoCompleteBox,
DataPager
介绍
Silverlight 3.0 控件一目:

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

  • GPU 加速 – 对 GPU 加速的支撑
  • Out-Of-Browser –  浏览器外运转,即支持脱离浏览器运行
  • 应用程序库缓存 – 将 dll(zip) 缓存到客户端浏览器中 
  • 联合 ResourceDictionary – 整合不同位置的 ResourceDictionary 
  • 应用程序扩展服务 – 通过扩张 Application 来供附加服务
  • Silverlight 插件对象的初长效益 – 在 Silverlight 3.0 中 Silverlight
    插件对象的新添效益

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

6、稳扎稳打Silverlight(38) – 3.0过滤镜的BlurEffect, DropShadowEffect,
自定义滤镜, 3D效果的PlaneProjection,
位图API之WriteableBitmap
介绍
Silverlight 3.0 图形系统的有关新增功能

  • 新增了 Closing 事件
  • 落实程序于 OOB 模式下的自动更新
  • NotificationWindow – 以 OOB 模式下显得通知窗口,也便是 toast
  • 兑现自定义之 NotificationWindow
  • Element to Element Binding – Element 到 Element 之间的绑定 
  • RelativeSource – 一个恢宏标记,用于指定关联数据源为 Self 或
    TemplatedParent 
  • 动态修改样式 – 在 Runtime 时修改样式 
  • 体继承 – 通过 BasedOn 使有样式可以持续自另一个体裁 
  • 打定义光标 – 通过 CaretBrush 自定义输入框的光标的体 

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

  • AutoCompleteBox – 自动完成控件。当用户输入有音后,此控件可以因指定的过滤算法在一个下拉框中列支出相当配项
  • DataPager – 分页控件 

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

5、稳扎稳打Silverlight(37) –
3.0动画之Easing(缓动效果)
介绍
Silverlight 3.0 动画的缓动效果:

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

7、稳扎稳打Silverlight(39) – 3.0通信的二前行制XML通信,
本地连接
介绍
Silverlight 3.0 通信的初长效益

4、演示如何落实由定义之 NotificationWindow
generic.xaml

  • ChildWindow – 用于在父窗体前弹有一个之子窗体
  • SaveFileDialog – 用户发起的保存文件对话框(OpenFileDialog –
    打开文件对话框)
  • HeaderedItemsControl – 呈现标题和集数据的控件
  • VirtualizingStackPanel – 虚拟化的 StackPanel(即只有生成需要出示的 UI
    元素。当绑定了汪洋数码,而某时仅展示其中同样有些一些的时候,使用此控件则只是大幅增长见效率) 

        public event EventHandler<EventArgs> Closed;
    }
}

3、稳扎稳打Silverlight(35) – 3.0控件之ChildWindow, SaveFileDialog,
HeaderedItemsControl,
VirtualizingStackPanel
介绍
Silverlight 3.0 控件一见到:

        <StackPanel HorizontalAlignment=”Left”>

稳扎稳打 Silverlight 3.0 系列文章索引

<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”>

OK
[源码下载]

using System.Windows.Controls.Primitives;

  • TreeView – 树控件
  • ListBox – 改进:支持多选择
  • DataGrid – 改进:结合 PagedCollectionView 实现多少分组,
    增加了部分编纂数据的有关事件, 结合 DataAnnotations 实现数量证实,
    等。。。
  • MediaElement – 增加了对视频 H.264 编码格式的支撑,和针对板 AAC
    编码格式的支持 

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

  • 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)

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

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

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;

作者:webabcd

2、演示如何促成程序在 OOB 模式下的自动更新
AutoUpdateDemo.xaml

[源码下载]

            <TextBlock Text=”OOB 模式下于定义 NotificationWindow 的内容以及体制详见本目录下之 CustomNotificationWindowDemo.xaml” Margin=”5″ />

4、稳扎稳打Silverlight(36) – 3.0控件之TreeView, ListBox增强,
DataGrid增强,
MediaElement增强
介绍
Silverlight 3.0 控件一探望:

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

  • 仲上制XML通信 – 与 WCF 服务内部通信,可以使二迈入制 XML
    传递数据(提高传输性能) 
  • 本地连接 – 允许客户端的个别单 Silverlight
    程序中直接开展通信(不用经过服务端)

Demo.xaml.cs

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

        // 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)
        {
        }

稳扎稳打Silverlight(44) – 4.0浏览器外运转(Out Of
Browser)之OOB的提高及其新增的NotificationWindow

using System.Net.NetworkInformation;

            // 网络状态来变更时所点的波,可以拔网线看成效
            NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);

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

<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”>

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;

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

[索引页]
[源码下载]

                notify.Content = lblMsg;

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

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

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

<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>

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

/*
 * 本例演示如何落实由定的 NotificationWindow
 */

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

CustomNotificationWindowDemo.xaml

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

            // 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);
                };
            }
        }

示例
1、OOB(Out Of Browser)模式之习,以及该新增的 Closing 事件
Demo.xaml

3、演示 NotificationWindow(toast) 的功力,以及那与 Popup 的对待
NotificationWindowDemo.xaml

                notify.Show(3000);
            }
            else
            {
                MessageBox.Show(“请于浏览器外运行”);
            }
        }
    }
}

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

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

/*
 * NotificationWindow – 在 OOB 模式下显得通知窗口,也不怕是 toast
 */

        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();
            }
        }
    }
}

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

            <TextBlock Text=”OOB 模式下网状况的检测,以及程序的升迁详见本目录下的 AutoUpdateDemo.xaml” Margin=”5″ />

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

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

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

/*
 * 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)
 */

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

/*
 * 调试 OOB 模式下的 Silverlight 程序:启用 OOB 模式,将 Silverlight 项目安装为启动项目,然后运行即可
 */

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

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

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

            Popup popup = new Popup();

CustomNotificationWindowDemo.xaml.cs

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

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

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

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

/*
 * 本例用于演示 Closing 事件
 * Application.Current.MainWindow – OOB 模式下之应用程序窗口。属性值为 System.Windows.Window 类型
 * Window.Activate() – 激活窗口,使之具有典型,并置于最前边
 * Window.IsActive – 是否也激活窗口(仅 get)
 * Window.Close() – 关闭窗口
 * Window.Closing – 窗口关闭前点的波。事件参数为 System.ComponentModel.ClosingEventArgs 类型
 *     ClosingEventArgs.IsCancelable – 是否可以取消窗口的闭馆事件
 *     ClosingEventArgs.Cancel – 是否撤销窗口的倒闭事件
 */

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

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

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

            popup.Child = border;

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

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;

CustomNotificationWindow.xaml

CustomNotificationWindow.cs

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

</ResourceDictionary>

/*
 * 本例演示 Silverlight 应用程序在 OOB 模式下之自动更新
 * 注1:Silverlight 应用程序根据 Assembly Version 来判定是否用创新
 * 注2:程序下充斥成功后,需要重新开 Silverlight 应用程序,这样运行的才是创新后底次序
 * 
 * NetworkInterface.GetIsNetworkAvailable() – 网络是否中
 * NetworkChange.NetworkAddressChanged – 网络状态发生变化时所点的风波
 * Application.CheckAndDownloadUpdateAsync, Application.CheckAndDownloadUpdateCompleted – 一针对性异步方法/事件,用于更新浏览器外运行的 Silverlight 程序(从服务器上下充满新的本)
 * CheckAndDownloadUpdateCompletedEventArgs.UpdateAvailable – 是否都打响更新了本子
 * CheckAndDownloadUpdateCompletedEventArgs.Error – 下载更新时来了老大
 */

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

<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” />

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

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

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

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

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;

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

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

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

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

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

NotificationWindowDemo.xaml.cs

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

            notify.Show(3000);
        }
    }
}

<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”>

AutoUpdateDemo.xaml.cs

        //  UI 元素在应用程序中展示之前所调用的法
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            popup.IsOpen = true;
        }
       
        private void btnShowNotificationWindow_Click(object sender, RoutedEventArgs e)
        {
            /*
             * NotificationWindow.Content – toast 所展示的情节
             * NotificationWindow.Show(int durationInMilliseconds) – 显示 toast,并以指定时间晚隐藏 toast
             * 
             * 注:每个 Silverlight 应用程序在同一时间只能显示一个 toast 。如果以一个 toast 正在显示的同时调用 NotificationWindow.Show() 则会吸引那个
             */

介绍
Silverlight 4.0 OOB 模式之初特点:

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

    <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>

            notify.Content = custom;

<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” />

            <TextBlock Text=”OOB 模式的 toast(以及同 Popup 的对比)详见本目录下的 NotificationWindowDemo.xaml” Margin=”5″ />

OK
[源码下载]

作者:webabcd

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

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