Welcome to MSDN Blogs Sign in | Join | Help

Mike Ormond's Blog

In my world, things would be simpler than this...

News

  • Add to Technorati Favorites

    These postings are provided "AS IS" with no warranties, and confer no rights. The use of any script / code samples is subject to the terms specified here.

Silverlight OnFullScreenChange and AddEventListener()

I spent too long this weekend trying to hookup an event handler to the OnFullScreenChange event in my Silverlight 1.0 application using something like the following:

this.plugIn.content.addEventListener("OnFullScreenChange", 
    Silverlight.createDelegate(this, this.onFullScreenChanged));

And various variations of "onFullScreenChanged", "FullScreenChanged", "fullScreenChanged" etc. All I got from Silverlight was a rather unhelpful:

Picture1

There's a critical statement in the documentation for AddEventListener which I had overlooked:

"The AddEventListener method registers an event listener on a UIElement-derived object, such as a Canvas or Image."

The content object is not a UI-Element derived object - it's not the same thing as your root element (canvas). This is somewhat confusing but Ian Griffiths has a great description over here. What you need to do instead is simply:

this.plugIn.content.onfullScreenChange = 
    Silverlight.createDelegate(this, this.onFullScreenChanged); 

Posted: Monday, February 18, 2008 9:05 AM by MikeOrmond
Filed under:

Comments

discorax said:

Oh, that's super helpful. Glad I read this so I didn't have to spend a weekend figuring that one out. Thanks!

# February 18, 2008 6:38 PM

Community Blogs said:

Chris Cavanagh gave up the source for his WPF Skinning application, Mike Ormond shares his OnFullScreenChange

# February 18, 2008 7:41 PM

Chris Dreger said:

I am attempting to make a Silverlight video player, (exported from Encoder and modified in Blend) play the first section of a video locked to a specific size (full screen disabled) and then at the second section (chapter) play full screen automatically, and then at the next or last section, go back to the smaller size within the player.

Do you have any ideas on how to do this?

thanks.

-Chris

# February 19, 2008 6:05 PM

Chris said:

Hi Mike. I got a response from a Chad Campbell (author of 'Silverlight 2.0 in Action' and he said, "This cannot be done.  Full screen mode can only be initiated by a user action (i.e. a click event).  This is done this way for security reasons (i.e. spoofing). "

If you know of differing information, please let me know.

Thanks.

Chris

# February 20, 2008 11:24 AM
New Comments to this post are disabled
Page view tracker