How do I resize a silverlight app based on its content?

I have a simple application that I would like to resize when loading content.

For example, let's say I upload an image with a size of 100.

How do I resize the container that displays the silver light?

0


a source to share


2 answers


Decision -

Instead of 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());

      

+1


a source


After resizing the container, you may receive a notification:



    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;

        };

    }

      

+1


a source







All Articles