[XNA , WPF] XNA 에서 코드레벨로 WPF 생성하기
필요한 레퍼런스는
System.Windows.Presentaion
System.Xaml
PresentationCore
PresentationFramework
이고 필요한 using 은
using System.Threading;
using System.Windows;
using System.Windows.Controls;
되겠다.
Created with colorer-take5 library. Type 'csharp'XNA , Game1.cs 중 일부 Texture2D tex; protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); tex = Content.Load<Texture2D>("logo2"); this.Window.Title = "currentThread :" + Thread.CurrentThread.ManagedThreadId; //[0] 새로운 wpf 어플을 생성하기 위해 새로운 스레드 생성 , 스레트타입은 STA Thread t = new Thread(startThread); t.ApartmentState = ApartmentState.STA; t.Start(); } void startThread() { //[1] Application 객체를 선언하고 생성 Application app = new Application(); //[2] StartUp 이벤트를 건다. app.Startup += new StartupEventHandler(app_Startup); //[3] 그리고 시작! app.Run(); } void app_Startup(object sender, StartupEventArgs e) { //[4] 새로운 윈도우를 생성한다 Window win = new Window(); win.Width = 300; win.Height = 300; win.Title = "currentThread :" + Thread.CurrentThread.ManagedThreadId; //[5] 새로운 윈도우를 표시한다 win.Show(); Button bt = new Button(); bt.Content = "XNA 에서 WPF 생성��기"; win.Content = bt; } |
역시나 윈도우폼과 마찮가지로 STA 타입의 스레드가 필요하다.
그러나 윈폼과 Application 의 사용법이 다른점에 주의! (그냥 Application.Run 하면 안된다.)
또한 닷넷4.0의 경우 System.Xaml 을 필히 참조 시켜줘야 겠다.
'XNA' 카테고리의 다른 글
[DisplayObject2D] 시작 (112) | 2011.05.02 |
---|---|
[간단메모] Texture2D , Alpha Color (5443) | 2011.04.27 |
[XNA , WPF] XNA 에서 코드레벨로 WPF 생성하기 (165) | 2011.02.01 |
[XNA on TUIO] CCV 1.4 <- TUIO -> XNA (128) | 2010.12.18 |
[KINECT] 키넥트 개봉기와 설치 드라이버 (Windows x64 on MacBook) (192) | 2010.12.11 |
[KINECT] 2010.12.03일자 새버전 OpenKinectCamera class 공개 (32) | 2010.12.06 |
XNA
2011.02.01 16:03