Microsoft Silverlight, versions 3 and greater
Silverlight managed programming model and Silverlight XAML
Silverlight content in a user agent host that supports browser zoom
This technique relates to:
See User Agents Supported for general information on user agent support.
Not all user agents implement a browser zoom feature. Of those that do as of 30 March 2011, best results are obtained when the user agent is Internet Explorer or Firefox.
Note that on Firefox, the Ctrl+(+) accelerator for browser zoom may not work due to an issue where if the plugin (Silverlight) has focus, it traps all keyboard events, even those that would ordinarily be the user agent's set of accelerators.
Some versions of Firefox have a browser zoom mode that zooms text only. This functionality is based on text by an HTML definition, so selecting this option does not zoom any Silverlight content (whether it is text by any Silverlight definition, or not.)
Internet Explorer version 8 has an "AutoZoom" feature that is based on operating system DPI. Silverlight accounts for this through a native sizing behavior, but that behavior is not relevant for this technique because the DPI settings are not typically used as a primary technique by Web technology users for accessibility purposes. DPI is more relevant to device choices, or specific operating system features.
The objective of this technique is to support or anticipate existing browser zoom features effectively when users interact with the Silverlight application. This technique explains how the Silverlight content area reacts to the browser zoom feature implemented by some user agent hosts. Silverlight content and layout properties are based on physical screen pixel measurements. When the browser zoom is engaged, Silverlight content scales correctly for the zoom factor, and uses the same zoom factor as any surrounding HTML content.
Browser zoom is relevant for accessibility and Silverlight because it is likely to be the zoom /scaling feature enabled by the browser host that Web technology users are the most familiar with as a technique for increasing the text size in Web content.
Built-in support for browser zoom was introduced as a feature in Silverlight
version 3. Older documents on the Web might describe techniques that
were relevant for Silverlight version 2, where dealing with browser
zoom required JavaScript handling of the Resized
event,
and developers manually applied a ScaleTransform
to Silverlight
content to scale it up. Silverlight has a "quirks mode" that
detects existing handlers that might still use the older techniques.
Built-in zoom not active in these cases, so that applications can avoid
doubling or otherwise mishandling the user agent's zooming behavior.
Silverlight also provides the ability to disable the built-in browser zoom handling and rendering behavior. This is sometimes done in order to suppress some of the aliasing and distortion artifacts that host-level scaling can introduce, particularly for video content or certain uses of text. In these cases, application authors might consider other Silverlight techniques for scaling the user interface, perhaps specifically only for the text elements on a page. When an application disables the built-in zoom behavior and rendering for Silverlight content, the browser still retains its zoom settings, and that setting applies to other content outside of Silverlight such as the hosting HTML.
This example has a UI defined in XAML and logic defined in C#. The UI shows the zoom factor, and also demonstrates what happens when built-in browser zoom handling is deliberately disabled. Note that the zooming factor as reported by the API is still retained even when Silverlight built-in zoom scaling is disabled deliberately. The following is the XAML UI:
<UserControl x:Class="BrowserZoom.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<StackPanel x:Name="LayoutRoot" Background="White">
<TextBlock>Some text you can zoom.</TextBlock>
<Button Click="Button_Click">Toggle built-in zoom handling</Button>
<StackPanel Orientation="Horizontal">
<Button Click="Button_Click_1">Query current zoom factor</Button>
<TextBox IsReadOnly="true" Name="zoomf"
Text="{Binding Path=reportZoom}"/>
</StackPanel>
</StackPanel>
</UserControl>
The following is the C# logic:
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (!Application.Current.Host.Settings.EnableAutoZoom == false) {
Application.Current.Host.Settings.EnableAutoZoom = false;
}
else
{
Application.Current.Host.Settings.EnableAutoZoom = true;
}
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
zoomf.Text = Application.Current.Host.Content.ZoomFactor.ToString();
}
}
This example is shown in operation in the working example of Browser Zoom.
Resources are for information purposes only, no endorsement implied.
Using a browser that supports Silverlight, open an HTML page that references a Silverlight application through an object tag. The browser being used for the test must support a browser zoom feature, and the feature must be turned on as a user preference.
Verify that the Silverlight application enables auto zoom (no Silverlight application-specific code or markup has set EnableAutoZoom API to false).
Test the zooming feature of the user agent. Verify that browser zoom factors apply to the Silverlight content.
#2 and #3 are true.
If this is a sufficient technique for a success criterion, failing this test procedure does not necessarily mean that the success criterion has not been satisfied in some other way, only that this technique has not been successfully implemented and can not be used to claim conformance.