2010-03-25 44 views

回答

5

添加System.Windows.Forms.dll程序和System.Drawing.dll程序引用,並嘗試這個辦法:

public partial class App : Application 
{ 
    protected override void OnStartup(StartupEventArgs e) 
    { 
     base.OnStartup(e); 

     foreach (var screen in System.Windows.Forms.Screen.AllScreens) 
     { 
      var window = new Window1 
      { 
       WindowStartupLocation = WindowStartupLocation.Manual, 
       WindowState = WindowState.Maximized, 
       WindowStyle = WindowStyle.None, 
       Title = screen.DeviceName, 
       Width = screen.Bounds.Width, 
       Height = screen.Bounds.Height, 
       Left = screen.Bounds.Left, 
       Top = screen.Bounds.Top, 
      }; 
      window.Show(); 
     } 
    } 
} 

不要忘記從App.xaml中刪除的StartupUri = 「Window1.xaml」。

+0

我想現在怎麼運行Window1.xaml? – abramlimpin 2010-04-01 17:01:27

+0

var window = new Window1 ...; window.Show(); // < - - 這個調用取代了StartupUri =「Window1.xaml」 – 2010-04-02 13:01:50