2010-03-25 43 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