Sharker Khaleed Mahmud Silverlight Tips & Tricks

January 10, 2010

Tricks and Tips 11 : Get screen resolution in silverlight

MainPage.xaml.cs

using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;

namespace Tips
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainPage_Loaded);
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            string Width = HtmlPage.Window.Eval(“screen.width”).ToString();
            string Height = HtmlPage.Window.Eval(“screen.height”).ToString();

            MessageBox.Show(string.Format(“Current resolution : {0} X {1}”, Width, Height));
        }
    }
}

Sharker Khaleed Mahmud
Software Developer
(MCP,MCTS,MCPD[web])

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.