Silverlight使用全屏实在是简单

Posted on August 23, 2007 by Fdream


在网页中浏览视频,使用全屏播放往往能够给用户更好的体验,Silverlight对全屏支持很好,简单几行代码就能搞定全屏的问题。

BrowserHost对象有个属性就是IsFullScreen,设置其为True时就可以实现全屏,设置为False就可以退出全屏,默认情况下按ESC时就可以退出全屏。后来发现,按Alt+Tab也可以,^_*

简单的代码如下:

public void Page_Loaded(object o, EventArgs e)
{
//Required to initialize variables
InitializeComponent();

fullButton.MouseLeftButtonDown += new MouseEventHandler(bgRect_MouseLeftButtonDown);
}

void bgRect_MouseLeftButtonDown(object sender, MouseEventArgs e)
{
if (System.Windows.InteropBrowserHost.IsFullScreen)
{
fullButton.Text = “Click Here to FullScreen”;
System.Windows.InteropBrowserHost.IsFullScreen = false;
}
else
{
fullButton.Text = “Click Here Return to Window”;
System.Windows.InteropBrowserHost.IsFullScreen = true;
}
}

分享 |
Categories:
Silverlight/C#
Tags:
Comments:
1 Comment
Views:
11,892 Views

Related Posts

One Response to <Silverlight使用全屏实在是简单>

  1. Great post I must say. Simple but yet interesting. Wonderful work!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>