Silverlight获取机器或浏览器的分辨率
为了适应不同的浏览器的屏幕变化,有时候需要获取浏览器的分辨率。如下代码:
App.Current.Host.Content.Resized += new EventHandler(Content_Resized); LayoutRoot.MaxHeight = App.Current.Host.Content.ActualHeight / 1.5; LayoutRoot.MaxWidth = App.Current.Host.Content.ActualWidth / 1.4;
private void Content_Resized(object sender, EventArgs e)
{
LayoutRoot.MaxHeight = App.Current.Host.Content.ActualHeight / 1.5;
LayoutRoot.MaxWidth = App.Current.Host.Content.ActualWidth / 1.4;
}
有时候也需要知道浏览器的大小,如下:
HtmlPage.Window.GetProperty("innerWidth")
可以获取屏幕的宽度。

浙公网安备 33010602011771号