Friday, April 13, 2012

WPF Controls in XNA

http://www.c-sharpcorner.com/uploadfile/iersoy/windows-controls-and-wpf-usercontrols-inside-an-xna-game-project/
http://stackoverflow.com/questions/835878/wpf-textbox-not-accepting-input-when-in-elementhost-in-window-forms

But the textbox is still not receiving input.

Alternative is to render a separate window
Window window = new Window();
window.Content = control;
WindowInteropHelper helper = new WindowInteropHelper(window);
 helper.Owner = Window.Handle;
ElementHost.EnableModelessKeyboardInterop(window);
window.Show();


Have to Add Reference:
System.Xaml
WindowsFormsIntegration
System.Windows.Forms
PresentationCore
PresentationFramework

import

using System.Windows;
using System.Windows.Interop;
using System.Windows.Forms.Integration;


Run the program and you will get an error about STAThread
so add "[STAThread]" in eg.: 
Program.cs
just before "static void Main(String[] args)" 

No comments: