代码之家  ›  专栏  ›  技术社区  ›  aronchick

如何根据silverlight应用程序的内容调整其大小?

  •  0
  • aronchick  · 技术社区  · 16 年前

    我有一个简单的应用程序,我想改变大小时,我加载的内容。

    如何更改正在渲染silverlight的容器的大小?

    2 回复  |  直到 16 年前
        1
  •  1
  •   aronchick    16 年前

    解决方案--

    您需要浏览浏览器对象,而不是浏览页面。

    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());
    
        2
  •  1
  •   Braulio    16 年前

    调整容器大小后,您可以收到以下通知:

        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;
    
            };
    
        }