I've been looking into this a bit myself as well and was interested to see amadmonk's post saying he'd been trying it.
Admittedly, I haven't done a huge amount, but thought it would be an interesting project to have a go at. I haven't made a huge amount of progress at the moment, but here's a brief summary of what I have done:
1. Injecting WPF in a similar manner to WinForms (i.e. inject CLR then call a method to start WPF application) works fine* with no extra headaches to WinForms (except the STAThread attribute seems to be ignored, but can be fixed by manually calling SetApartmentState as Apoc said).
Code:
public static int DllMain(string arg)
{
var guiThread = new Thread(App.Initialise);
guiThread.SetApartmentState(ApartmentState.STA);
guiThread.Start();
return 0;
}
Code:
public static void Initialise()
{
App app = new App();
app.InitializeComponent();
app.Run(new MainWindow());
}
2. Running WPF off the same device as WoW seems to work* (or WoW off the same device as WPF, not sure which initialised first and haven't extensively tested yet). Caveats: WoW can't use a IDirect3DDevice9Ex (pretty sure my hooking function wasn't working, but if WoW uses any D3DPOOL_MANAGED then it wouldn't work off an Ex device anyway, as they don't support managed). However, WPF does seem to run fine* on a IDirect3DDevice9. This was checked by hooking Direct3DCreate9 and Direct3DCreate9Ex, and redirecting the latter to return the former. By no means am I saying this is definitive or accurate, and I can think of a few issues with my 'testing' anyway, but as I said these are my preliminary findings.
* When I say 'works fine' I'm generally meaning I am able to get a WPF window showing within WoW. This is pretty much a blank window with a background from resources. In the same way as WinForms, this is a separate window that can be moved around independently of the WoW window (windowed mode).
None of this really leads to a WPF HUD-like integration where WPF controls are overlayed over the DirectX render (which if I understand correctly is actually what you're after - and what I'd ideally love to achieve).
The next area I'm intending to look at is to see if I can somehow trick WPF into constructing a WPF window from WoW's main window HWND. Or at the very least perhaps load a XAML control tree and attach it / render it from a HwndSource.
@Apoc: I'm not sure what you were meaning with regards to having to manually bugger around to set the resource assembly? In my experience, I've been able to inject a WPF window and access resources in XAML without having to do any code I wouldn't do in a standard WPF app..
i.e.:
Code:
<Application.Resources>
<LinearGradientBrush x:Key="Gradient1">
<GradientStop Color="#FFC61616" Offset="0"/>
<GradientStop Color="#FFB17777" Offset="0.932"/>
</LinearGradientBrush>
</Application.Resources>
Code:
<Grid Background="{StaticResource Gradient1}">
</Grid>
works fine for me without having to do anything unusual.
EDIT: Hmm no sooner said than I go and change some stuff and start getting XAML parse exceptions with Resources not being found. Interesting, will try your code and see what happens.