Popup 弹出窗口
<UserControl x:Class="Silverlight20.Tip.PopupDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="LayoutRoot" Background="White">
<Button x:Name="btnPopup" Content="弹出新窗口" Margin="5" Width="80" Height="40" Click="btnPopup_Click" HorizontalAlignment="Left" VerticalAlignment="Top" />
</Grid>
</UserControl>CS:
/*
* 如果需要 Silverlight 宿主可以使用 HtmlPage.PopupWindow() 弹出新窗口,则需要如下参数
* <param name="allowHtmlPopupWindow" value="true" />
* 此参数:同域时默认为 ture ; 跨域时默认为 false
*/
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.Browser;
namespace Silverlight20.Tip
{
public partial class PopupDemo : UserControl
{
public PopupDemo()
{
InitializeComponent();
}
private void btnPopup_Click(object sender, RoutedEventArgs e)
{
// HtmlPopupWindowOptions - 需要弹出的新窗口的参数(如果浏览器是以标签的形式打开新窗口,则此参数无效)
HtmlPopupWindowOptions opt = new HtmlPopupWindowOptions();
opt.Left = 0;
opt.Top = 0;
opt.Width = 320;
opt.Height = 240;
// HtmlPage.IsPopupWindowAllowed - 指定 Silverlight 宿主是否可以使用 HtmlPage.PopupWindow() 来弹出新的浏览器窗口
// HtmlPage.PopupWindow() - 弹出新窗口
if (true == HtmlPage.IsPopupWindowAllowed)
HtmlPage.PopupWindow(new Uri("http://webabcd.cnblogs.com/", UriKind.Absolute), "newWindow", opt);
}
}
}


浙公网安备 33010602011771号