Skip to content

Instantly share code, notes, and snippets.

@hilapon
Created January 14, 2015 06:56
Show Gist options
  • Save hilapon/8f65dc9bfc48dd8697c6 to your computer and use it in GitHub Desktop.
Save hilapon/8f65dc9bfc48dd8697c6 to your computer and use it in GitHub Desktop.
WPF の Hello world (その2)
using System;
using System.Windows;
namespace ConsoleApplication3 {
class Program {
[STAThread]
static void Main(string[] args) {
var window = new Window() { Content = "Hello world" };
window.ShowDialog();
}
}
}
@hilapon
Copy link
Author

hilapon commented Jan 14, 2015

コンソールアプリからWPF Window を起動するサンプル。WPF Window の起動はシングルスレッドアパートメントでないと例外が発生するため、STAThread属性を指定してある。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment