先加入System.Windows.Forms Reference



於程式碼寫入以下程式

using System.Windows.Forms;

...

namespace XXXX

{

        public partial class Window1

        {

                private void WindowLoaded(object sender, RoutedEventArgs e)

                {

                    System.Console.WriteLine("windnowloaded");


                    //取得螢幕大小

                    double Sheight = Screen.PrimaryScreen.Bounds.Height;

                    double Swidth = Screen.PrimaryScreen.Bounds.Width;

                    Window.Height = Sheight;

                    Window.Width = Swidth;

                    System.Console.Write("Sheight:" + Sheight);

                    System.Console.WriteLine(", SWidth:" + Swidth);


                }

        }

}

狼翔月影 發表在 痞客邦 PIXNET 留言(0) 人氣()