Filling Browser Window with Silverlight Application

后端 未结 4 1850
[愿得一人]
[愿得一人] 2021-01-04 06:40

I want my Silverlight app to fill the entire browser window. I\'ve set the plugin object width and height to 100%, and set my LayoutRoot container\'s height and width to Aut

4条回答
  •  隐瞒了意图╮
    2021-01-04 07:33

    If you've got a fairly complex HTML layout and can't rely on fixed positioning then you can make the #silverlightControlHost div resize using the following:

    private bool _hasResized;
    
    protected override Size ArrangeOverride(Size finalSize)
    {
        if (!_hasResized)
        {
            HtmlPage.Document.GetElementById("silverlightControlHost").SetStyleAttribute("height", finalSize.Height.ToString());
            _hasResized = true;
        }
    
        return base.ArrangeOverride(finalSize);
    }
    

    You can put this inside MainPage.cs or if you have nested UserControls, then the control that requires the most height. I'm also using the following XAML and the default HTML Visual Studio provides

    
    

    I haven't tested it without these settings, as far as I know Auto is the default.

提交回复
热议问题