Silverlight HtmlPage使用之一 弹出新窗口

首先引用using System.Windows.Browser命名空间

  xaml代码

< UserControl x:Class= "SilverlightApplication1.HtmlPageControl"
    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 Content= "PupopWindow"  Height= "23"  HorizontalAlignment= "Left"
 Margin= "12,12,0,0"  Name= "button1"  VerticalAlignment= "Top"  Width= "97"  
Click=
"button1_Click"  />
    < /Grid>
< /UserControl>
 

  cs代码

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            HtmlPopupWindowOptions option=new HtmlPopupWindowOptions();
            option.Directories=true ;//是否开启ie地址栏
            option.Height=300;//浏览器窗口高度
            option.Width=300;//浏览器窗口宽度
            option.Status=true;//状态栏是否可见
            option.Location=true;//是否弹出窗口
            option.Menubar=true;//菜单栏是否可见
            option.Resizeable=true;//是否可调整窗口高宽度
            option.Scrollbars=true;//滚动条是否可见
            option.Toolbar=true;//工具栏是否可见
            option.Left=option.Width/2;//窗口的X坐标
            option.Top=option.Height/2;//窗口的Y坐标
            HtmlPage.PopupWindow(new Uri("http://www.baidu.com"), "_blank", option);


        }

本文来自mldark的博客,原文地址:http://hi.baidu.com/mldark/blog/item/fbf51b2ad08c3eece7cd40eb.html

你可能感兴趣的:(浏览器,IE,Class,工具,silverlight,button)