Skip to main content

Microsoft Silverlight

Answered Question How do I add a button to toggle fullScreen mode?RSS Feed

(0)

SteveRicketts
SteveRic...

Member

Member

3 points

26 Posts

How do I add a button to toggle fullScreen mode?

I have a Silverlight video that I want to put into fullScreen mode.  I understand fullScreen mode can only be envoked by using a Silverlight control like a button or mouseclick (which seems a bit silly).  I cannot use the mouseclick because I'm using mouseclicks for another function so I want to add a button.  However, I can't seem to get the syntax right.  I'm using a script to create the xaml in my .asp page:

 <script id="xaml" type="text/xaml">
   <Canvas xmlns="http://schemas.microsoft.com/client/2007"
   Loaded="canvasLoaded"
   >
 <MediaElement Name="video" Source="<%=url%>"
 Width="<%=vWidth%>"
 Height="<%=vHeight%>"
 Stretch="Uniform"
 AutoPlay="True"
 CurrentStateChanged="currentStateChanged"
 MediaEnded = "mediaEnded"
 Opacity="100"
    />
   <Button Click="fullScreen" Content="test"></Button>
   </Canvas>
 </script>

The "<Button Click="fullScreen" Content="test"></Button> causes an error. 

 So, my question is: "How can I add a button to the control so I can call the full screen function?"

 Thanks for any help you can provide,

 sr

PS. Here is the rest of the Silverlight control code:

 <div id="ControlHost" style="position:absolute;top:0;left:0;">
  <object id="silverlightControl" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="<%=vWidth%>" height="<%=vHeight%>">
  <param name="source" value="#xaml"/>
  <param name="onerror" value="onSilverlightError" />
  <param name="onLoad" value="mediaLoaded" />
  <param name="onFullScreenChange" value="onFullScreenChanged" />
  <param name="onMouseLeftButtonUp" value="onMouseLeftButtonUp" />
  <param name="background" value="black" />
  <param name="minRuntimeVersion" value="2.0.31005.0" />
  <param name="autoUpgrade" value="true" />
  <param name="windowless" value="true"/>
  <a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
  <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
  </a>
  </object>
 </div>

Life more interesting viewed upside down.

Abhishek@TIL
Abhishek...

Member

Member

336 points

64 Posts

Re: How do I add a button to toggle fullScreen mode?

Hi Steve,

Visit the following link and you will get the solution

http://geekswithblogs.net/SilverBlog/archive/2008/06/10/full-screen-mode-in-silverlight-2.0-rtw-applications.aspx

Kindly mark this post as answered if it helped you

Abhishek Singh
Technical Lead
Technology Innovation Lab
http://abhishek4hcl.wordpress.com/

SteveRicketts
SteveRic...

Member

Member

3 points

26 Posts

Re: How do I add a button to toggle fullScreen mode?

Thanks for the response, but the problem is that I'm using classic .asp and need to add the button to the inline xaml.  I know how to kick the video into full screen when I'm in .net, but I can't figure out how to put a button in the xaml with Javascript and classic .asp.  Once I have a button that's "part of the control" I can call the onFullScreenChanged function.  It's making the button part of the control I don't get.

 sr

Life more interesting viewed upside down.

Wolf Schmidt (MSFT)
Wolf Sch...

Member

Member

489 points

79 Posts

Microsoft

Re: How do I add a button to toggle fullScreen mode?

You're using inline XAML. Inline XAML is supported under Silverlight 2, but ONLY when you use the JavaScript programming model and by using the non-managed object set in terms of creating from XAML. Despite the silverlight-2 in the object tagging it falls back to that behavior for any inline XAML source. Button happens to be in the managed object set, so you won't be able to get a literal (Silverlight) Button into your UI at least not a functional one with an applied visual from a template, and ability to handle the Click event by any means.

You could be using something from the .asp side that looks like a button, and wire that. OR you could use some other primitive (suggest Rectangle or Canvas or maybe StackPanel if you want some internal layout) to be your Button. But as you mention you're using mouse clicks for something else, so that presents a problem you'll probably have to solve yourself with casing by source.

SteveRicketts
SteveRic...

Member

Member

3 points

26 Posts

Re: How do I add a button to toggle fullScreen mode?

lol.. was that English?... I'm going to have to study that a bit!... head already hurts!  ;-)

Let me see if I've got this...

 I'm using inline XAML which is unmanaged and buttons are basically in managed code and fall outside the model so I can't create a button in inline XAML that will be accepted.

 I have a button on the .asp side that triggers a fullScreen event in Silverlight, but I thought that didn't count because you can only kick the video into full screen from a "user interaction" on the Silverlight control.

 But I can create a Rectangle in inline XAML and use that as my button... but there is a question that if I'm clicking that it may not work because I've got a div over the actual Silverlight control that's trapping the mouse clicks.

"Casting by Souce" has me completely confused.  Have no idea what that is... My IQ points just dropped 20 or more...

I'll play with this a bit.  Maybe I can move the top of the div down far enough to make room for a rectangle I can click on.  I'll be in Canada for the next couple of days so I won't have any time to try this out for a while.

Many thanks for the response, very much appreciated even though it makes me feel a bit stupid.  ;-)

 sr

Life more interesting viewed upside down.

Wolf Schmidt (MSFT)
Wolf Sch...

Member

Member

489 points

79 Posts

Microsoft
Answered Question

Re: How do I add a button to toggle fullScreen mode?

Hmmm. I will try to localize myself. (BTW, this won't be the first time Wink )

Inline XAML as value of source property of a Silverlight plug-in object tag tells the Silverlight plugin's core code that you are using the JavaScript programming model, and the range of objects you can use is limited under that model. Button is not in that range, so you can't use it. See here for the list of objects that ARE usable in JSAPI.

ASP button: you are probably correct about not being allowed to kick off FullScreen=true from there, I keep forgetting about the pesky but necessary "user interaction" restriction. So nevermind.

Casing by source: meaning, if you're not sure whether you're getting an uncanceled bubbling mousedown from a child element, or are getting a deliberately bubbled-up event, get window.event.srcElement and then branch your script depending on whatever property you have set or can find in the DOM that is useful, be that tagName, id, etc.

 

venkat352
venkat352

Member

Member

5 points

3 Posts

Re: How to do the full screen for a selected objects

Hi,

Pls any one can help me. am having problem with doing full screen for a selected objects.what am doing is when am clicking on addtext button means some textblock is ading on to the grid and also adding some rectangles,ellipse,images but i dont know how to do the full screen for selected objects.

Pls give me the code for this

And am using .net3.5 and silverlight2

 Thanks

Venkat

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities