Ok this is the problem. I have a basic web site, which has buttons. those buttons are run through javascript and then the code goes in C# and then it does various things with the Silverlight gantt control.
For example if I want to ZOOM IN the gantt control I go like this:
<button id="zoomIn" onclick="SlZoomIn()">Zoom In</button>
then in javascript:
function SlZoomIn() {
var control = document.getElementById("SilverlightPlugIn");
control.Content.SilverPlan.JsZoomIn();
}
then in C#:
[ScriptableMember]
public void JsZoomIn()
{
try
{
gantt.ZoomBySteps(1);
}
catch (Exception e)
{
MessageBox.Show("Zoom In does not work.");
}
}
This all works fine, but when I want to do things with the gantt that require Events, this is a problem. For example, if I want to print or fullscreen my gantt control. How can I do this?
In C# the code for this is:
private void fullScreen(object sender, RoutedEventArgs e)
{
Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen;
}
But what do I have to do in javascript to trigger this method? when the user clicks on the button fullscreen?
There would be no difference in calling this code from JavaScript compared to your previous example, except that the Silverlight plug-in imposes security restrictions for several things, including full-screen mode, print and file dialogs. These mean that these actions have to be initiated by the user clicking or typing something. Explained here at MSDN.
Therefore you cannot do this from JavaScript, even when the user presses a button outside of the Silverlight plugin – the user will have to click something within the Silverlight plugin, for example a button which raises an event which you handle in your C# code, and take an action directly.
In the case of full-screen, you will find if you are mixing HTML/JavaScript content with Silverlight that the Silverlight full-screen very likely does not at all do what you want – the Silverlight content will be full screen, and the HTML content will not be visible. You also can’t use keyboard input (mostly). I’d recommend resizing the Silverlight object within the HTML page (possibly combined with maximising the browser window).