tags:

views:

108

answers:

2

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?

+1  A: 

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());
aronchick
+1  A: 

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;

        };

    }
Braulio
this is even better than min, as it doesn't require to know the plugin id!
aronchick
er mine .
aronchick
Sorry, as I'm trying to implement this, this is only for getting the size, not for setting the size of the SL host on the page.
aronchick