Reputation: 1234
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 youtube), is there a way to switch just the 'MediaElement' control to fullscreen?
Upvotes: 0
Views: 2187
Reputation: 5488
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
Upvotes: 0