Silverlight – Full Screen Support

Silverlight can display in either full-screen or embedded mode:

Embedded Mode : the application displays within the  browser or an out-of-browser app window.

Full-Screen Mode : the application resizes to the current resolution of the monitor and is on top of all other windows.

The Content.IsFullScreen property gets or Sets the Silverlight apps full-screen mode. If you set  to true, the Silverlight app displays in full-screen mode, the default is  embedded mode. If a web page has several Silverlight plug-ins, only one   can be in full-screen mode. Also, the plug-in will not display HTML content in full-screen mode.

When a Silverlight plug-in is set to full-screen  it briefly show the message “Press ESC to exit full-screen mode”. This alerts users that the app is in full-screen mode, and give information about how to revert to embedded mode.

A user initiated action is required to enable Full-Screen mode. You can only programmatically switch to full-screen mode only in a user-input event handler otherwise the property setting will be ignored. Limiting the actions that enable full-screen mode ensures that the user is always the initiator of full-screen mode behavior.

When in full-screen mode, keyboard events are disabled. This  is a security feature  intended to minimize the potential for unintended information to be entered by a user. When in full-screen mode,  only  the following keys are active:

ENTER, UP ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, PAGE UP, PAGE DOWN, TAB, SPACEBAR,  HOME, END

(These restrictions do not apply for apps in Elevated Trust )

Posted in FAQ | Tagged | Leave a comment

Silverlight 4 – Elevated Trust

Prior to Version 4, Silverlight apps  ran in partial trust, which meant that all apps had to  run in a security sandbox. Sandboxed apps have limited access to the local computer have other restrictions  that helps prevent malicious behavior.

However partial trust restricts the usefulness of business applications which will need to access local files or operation in full screen mode. Silverlight 4 allows out-of-browser apps to be configured with Elevated Trust. To do this the designer sets the appropriate value in the app manifest, an existing app can be upgraded to Elevated Trust by having the manifest can be updated.

When a user installs an elevated trust out-of-browser application the default dialog box is replaced by a security warning which highlights that the app can access user data  and so should only be installed only from a trusted sources.

Posted in FAQ | Tagged | Leave a comment

Silverlight 4 Features – Mouse Wheel Support

Previously Silverlight forced developers had  to rely on helper classes from either DeepZoom or sample sites to implement mouse wheel scrolling.  Silverlight 4 introduces APIs to directly handle MouseWheel events. The MouseWheel API’s are very intuitive and easy to use. The MouseLeftButtonDown, MouseLeftButtonUp, MouseRightButtonDown, MouseRightButtonUp, MouseEnter, and MouseLeave events can all be registered and implemented as required.

The most common scenario will be implementing the MouseRightButtonDown even, the below example demonstrates implementing this event on a UI element:

private void Image_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
p.HorizontalOffset = e.GetPosition(null).X+22;
p.VerticalOffset = e.GetPosition(null).Y + 22;
p.IsOpen = true;
e.Handled = true;
}
Posted in Uncategorized | Leave a comment

Silverlight 4 Features – Print

One of  Silverlight’s most requested features – Print makes its debut with Silverlight 4. Silverlight’s Print functionality allows you to specify a XAML tree to print. The primary class for printing is the PrintDocument class which exposes several events which are used to call back ask how to print individual pages:

PrintDocument printDoc = new PrintDocument();
printDoc.DocumentName = "SilverLight 4 Demo Print";
printDoc.StartPrint += new EventHandler<StartPrintEventArgs>(printDoc_StartPrint);
printDoc.PrintPage += new EventHandler<PrintPageEventArgs>(printDoc_PrintPage);
printDoc.Print();

The PrintDocument class allows the wire of up pre- and post-print events to prepare and clean-up code.  The important element is PrintPage where the UIElement to print is passed to the PrintDocument object.  This UIElement be something in the visual tree  or something created virtually in-memory and not added to the visual tree.

Posted in Uncategorized | Tagged | Leave a comment