Unity App Embeded in WPF App Not working properly

I’m currently building an WPF aplication and using Unity to preview 3D objects. For that, I decided to embed Unity within my app, so it looks seamless. And It does! I just have 2 problems that I can’'t seem to fix and need your help to do so.

Problem 1: I cannot control the embeded Unity window.
When I run my WPF app, the embeded Unity app ocupies the same space as my application.
I have to maximize my application window in order to view what is behind Unity window.
I would like to control the size of the embeded Unity on load, and also when the WPF app is resized.

Problem 2: I am unable to get Input.GetAxis(“Mouse X”) (This allways returns 0)
If I run my Unity build manually (not through my WPF app), I can see a textbox on the top left corner outputting Input.GetAxis(“Mouse X”), but if I run my WPF app with the embeded Unity, the top left corner textbox will allways be 0.

Download both Unity and WPF sample projects.
https://www.dropbox.com/s/guyvmligl4e6pqx/Projects.rar?dl=0

PS: I said I’m currently building in WPF but that is wrong. I’ve already did this in WinForm but must convert it to WPF. I don’t have these problems in WinForm

I have nothing constructive to say to this as it’s been a while since I’ve worked in WPF.

However, I’ve added a DirectX viewport to both WinForms and WPF, and I remember it being a lot harder to do so in WPF in such a way it looked seamless, and did what I wanted (i.e. still able to draw WPF UI elements over on top of the DirectX viewport). Plus, it was slow as hell (much slower than WinForms).

So I ended up just rendering the DirectX stuff into a buffer in C++, then push that into a texture at the C# level. This at least gave me full flexibility over how to display it.

Like I said, it’s been a while since I’ve done this so I don’t have code to show. Hopefully that should help trigger some brainstorming.

By pushing that into a texture, were you still able to input interaction into DirectX (able to input mouse click events)?

Well, an input layer was added so that input events could be send to whatever needs these events. It’s better to keep a clear separation between the input implementation and listeners anyway, IMO.

In my case, a bunch of functions like OnTextureClick(x,y), OnTextureButtonDown(key), etc. were created and handled (after p/invoking down into C++).