aronchick
aronchick

Reputation: 7128

How do i resize a silverlight app based on its contents?

I have a simple app that I'd like to change the size of when I load the contents.

For example, let's say I load an image of size 100.

How do I change the size of the container in which the silverlight is being rendered?

Upvotes: 0

Views: 403

Answers (2)

Braulio
Braulio

Reputation: 1728

The once the container is resized you can get notified:

    public Page()
    {
        InitializeComponent();

        App.Current.Host.Content.Resized += (s, e) =>
        {

            // Place here your layour resize code...
            this.Width = App.Current.Host.Content.ActualWidth;
            this.Height = App.Current.Host.Content.ActualHeight;

        };

    }

Upvotes: 1

aronchick
aronchick

Reputation: 7128

Solution--

Rather than going through the page, you need to go through the browser object.

Here's the solution I found:

width = 200;
height = 200;

var host = HtmlPage.Document.HtmlPage.Plugin.Id);
host.SetStyleAttribute("width", width.ToString());
host.SetStyleAttribute("height", height.ToString());

Upvotes: 1

Related Questions