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:

    Silverlight.createDelegate(this, this.onFullScreenChanged));

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


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); 

Comments (5)
  1. discorax says:

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

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

  3. Chris Dreger says:

    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?



  4. Chris says:

    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.



Comments are closed.

Skip to main content