Skip to main content
Home Forums Silverlight Programming Programming with JavaScript How do I add a button to toggle fullScreen mode?
6 replies. Latest Post by venkat352 on June 18, 2009.
(0)
SteveRic...
Member
3 points
26 Posts
01-25-2009 11:14 AM |
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:
Abhishek...
336 points
64 Posts
01-25-2009 2:11 PM |
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
01-25-2009 6:10 PM |
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.
Wolf Sch...
489 points
79 Posts
01-26-2009 3:27 PM |
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.
01-26-2009 6:46 PM |
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. ;-)
01-26-2009 9:32 PM |
Hmmm. I will try to localize myself. (BTW, this won't be the first time )
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
5 points
3 Posts
06-18-2009 9:33 AM |
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