Munim
Munim

Reputation: 2768

Silverlight: Restricting app to resize with browser zoom

Suppose I have a silverlight application. Once running in browser if I press CTRL + the app gets zoomed in and for CTRL - it gets zoomed out. Simple and common behavior;the problem is once the user zoom in the app above 100%(ZoomFactor 1) some of my controls get clipped and some gets vanished. The reason behind this may be the View placement hierarchy,which is not my headache at all. What I want is to restrict the app's Zoom In capability so that the user can not zoom it after the ZoomFactor gets larger than 1. How to do that? I am trying following code to get the ZoomFactor:

    App.Current.Host.Content.Zoomed += (s, e) =>
                {
                    double factor=App.Current.Host.Content.ZoomFactor;
                    if(factor>1)
                    {
                        //restricting the app zooming when browser zoom is greater than 1.
                    }
};

I have searched a lot but could not find a suitable answer that could be of help. Some one please help me out. Thanks in advance.

Upvotes: 1

Views: 1608

Answers (2)

Misha
Misha

Reputation: 571

Add this to the HTML where your silverlight object is created:

   <param name="enableautozoom" value="false">

This should allow the silverlight object to zoom in uniform and not clip any objects

Upvotes: 3

Luke Woodward
Luke Woodward

Reputation: 64959

I think the best you can hope for is to disable zooming altogether:

        App.Current.Host.Settings.EnableAutoZoom = false;

But, to be honest, by disabling zooming you are making it difficult for users with poor eyesight to use your application. The whole point of zooming in is to allow users with poor eyesight to see more easily. If zooming in breaks your application, your application has accessibility issues.

It's possible to disable/restrict zooming in browsers, see, for example, this question, but that is something that users must do in their own browsers, not something that a Silverlight application can achieve.

Upvotes: 3

Related Questions