The Artima Developer Community
Sponsored Link

.NET Buzz Forum
How to tell the screen resolution from within a Silverlight app

0 replies.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a flat view of this topic  Flat View
Previous Topic   Next Topic
Threaded View: This topic has 0 replies on 1 page
Ashish Shetty

Posts: 402
Nickname: nerddawg
Registered: Oct, 2004

Ashish Shetty is a Program Manager at Microsoft.
How to tell the screen resolution from within a Silverlight app Posted: Apr 11, 2008 10:14 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Ashish Shetty.
Original Post: How to tell the screen resolution from within a Silverlight app
Feed Title: Even a chimp can write code
Feed URL: http://nerddawg.blogspot.com/rss.xml
Feed Description: Ideas on software and elsewhere by Ashish Shetty: erstwhile chimp and occasional re-inventor of the wheel.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Ashish Shetty
Latest Posts From Even a chimp can write code

There isn't a direct API for detecting the screen width and height from within a Silverlight app. Fortunately, JavaScript provides you a way, viz. via the screen.width and screen.height properties. So with a nifty use of Silverlight's HTML DOM Bridge, these values can be read with little issue.

int screenWidth = Int32.Parse(

HtmlPage.Window.Eval("screen.width").ToString()

);

int screenHeight = Int32.Parse(

HtmlPage.Window.Eval("screen.height").ToString()

);


Then when your app runs in fullscreen mode, you'd get the screen resolution using the Silverlight plug-in's ActualWidth and ActualHeight.

int screenWidth =

Application.Current.Host.Content.ActualWidth;

int screenHeight =
Application.Current.Host.Content.ActualHeight;

Read: How to tell the screen resolution from within a Silverlight app


Topic: What should you be learning this year? Previous Topic   Next Topic Topic: Windows 7 - Is Vista's end near?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use