开发者

Open MediaElement in FullScreen

There is a MediaElement in my silverLight4 Application that plays videos. There are also other controls in the form (listbox, buttons etc...). When vieweing a Video, i want the option to switch to Fullscreen, but only the video and not all the form (something like y开发者_StackOverflow中文版outube), is there a way to switch just the 'MediaElement' control to fullscreen?


Make your MediaElement the RootVisual of the app. Since you can't change the RootVisual once it's assigned you need to do something like so

private MainPage _mainPage = new MainPage();
private MediaElement _media = new MediaElement(); 

private void Application_Startup(object sender, StartupEventArgs e)
{
    Grid grid = new Grid();
    grid.Children.Add(_mainPage);
    this.RootVisual = grid;
}

public void FullscreenVideo()
{
    (this.RootVisual as Grid).Children.Clear();
    (this.RootVisual as Grid).Children.Add(_media);
    Application.Current.Host.Content.IsFullScreen = true;
}

If you call FullscreenVideo it should load your MediaElement into a fullscreen window

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜