Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Full screen silverlight 2 Player
9 replies. Latest Post by Frank87 on January 12, 2009.
(0)
Frank87
Member
5 points
59 Posts
01-12-2009 6:48 AM |
I have a player within a silverlight 2 web application. I need to set the player to fullscreen, but there are no properties that do that. How can I do it ??
davidezo...
Contributor
5684 points
872 Posts
01-12-2009 6:52 AM |
Hi,
check out this code:
http://www.shinedraw.com/animation-effect/silverlight-vs-flash-switching-to-full-screen/
01-12-2009 8:19 AM |
I've tried to use that code, but my application crashes if I use it...
MoHassan
467 points
149 Posts
01-12-2009 8:33 AM |
Hello,
You can't set silverlight control to fullscreen automatically, you need a user generated event like button.
First create button and react to the click event handler using the code below.
{
}
Good luck
Hassan
01-12-2009 8:53 AM |
My code is exactly like yours, but it doesn't work...
at this line:
private void FullScreen_Click(object sender, RoutedEventArgs e) { Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen;
my application crashes, and I have to end it with task manager, because it doesn't respond...
01-12-2009 9:02 AM |
Paste you code here both the XMAL and the code behind for this event, I will try to regenerate on my machine.
01-12-2009 9:13 AM |
The button that generates the fullscreen is this:
(xaml)
<Button Height="39" HorizontalAlignment="Right" Margin="0,0,350,187" VerticalAlignment="Bottom" Width="45" Content="Button" x:Name="FullScreen" Template="{StaticResource ButtonControlTemplate6}" Click="FullScreen_Click"/>
(page.xaml.cs)
private void FullScreen_Click(object sender, RoutedEventArgs e) { Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen; }
in the Content_FullScreenChanged there is this:
void Content_FullScreenChanged(object sender, EventArgs e) { double screenWidth = Application.Current.Host.Content.ActualWidth; double screenHeight = Application.Current.Host.Content.ActualHeight; }
Once I click on the button, my application crashes...
01-12-2009 9:25 AM |
Now it works, I don't know why, because I haven't made any change...
however, this code sets the fullscreen of the application, not the fullscreen of the player, so I've changed the width and the height of the player, and also the alignment(in the button), but it changed only the width and height, not the alignment...
how can I do to set the player in fullscreen ??
01-12-2009 9:33 AM |
void Content_FullScreenChanged(object sender, EventArgs e) {if (App.Current.Host.Content.IsFullScreen) { //Set everything you that need to be set here like the content of the button, the width and the height of the player and Collapse all the controls you do not want to see.
//Set everything you that need to be set here like the content of the button, the width and the height of the player and Collapse all the controls you do not want to see.
FullScButton.Content =
//reset everything to the original size and reverse everything you did.
01-12-2009 10:04 AM |
Thank you Hassan !! now it works
I have another question: my media element has 2 bars, one on the top and one on the bottom of the player. Is there any way to eliminate them ?