Dynamically adding ElementHost'd WPF UserControl to WinForms results in Black - wpf

I have a WPF user control inside an ElementHost that is inside a WinForms control to wrap it. I'm dynamically adding it to a tab control tab.
But when I do this, my WPF control is black.
How do I fix that?

There are many alternative solutions on the web to this one. However, what fixed it for us was to avoid "Fill" docking the element host within it's parent control. If you are using docking, then give it a try!
Unfortunately this can be one of those evil problems solved by experimentation and it'll turn out to be a one line fix!

It was my own mistake. I forgot to add the WinForms tab control panel (a 3rd party one) to the right class.

Related

Moving (dragging) HwndHost using mouse

Here's what I am trying to accomplish - To create an MDI application in WPF, which can host child web applications. I am using WPF webbrowser control to render web applications. WPF inherently doesn't seem to support MDI applications, so after a bit of searching, I found this project, which uses UI controls to simulate windows and manages them inside a WPF canvas. This approach seems to work reasonably well until I start adding webbrowser control object as an MDI child.
When I add webbrowser control as an MDI child, it always appears on top of other WPF elements including other MDI child controls (as shown below). From what I understand, webbrowser control always appears on top of any other WPF object except for window (and popup). Assuming that's true, I think I need to use actual WPF window to avoid overlapping issue.
The only solution i can think of right now is to wrap WPF window inside an HwndHost object and then add that as an MDI child. However it appears that a child window cannot have title bar. That means that i need to have a window that has a dummy title bar area (just like actual window title bar) and actual content area (which will show webbrowser control) as shown below (Red border is HwndHost object).
This approach seems to solve the overlapping issue. The next thing i need to try is to let users click on the dummy title bar and drag the MDI window inside the canvas element.
Questions -
Is my understanding about WPF webbrowser control overlapping behavior right? If not, what am i missing?
Is the second approach a step in right direction for accomplishing what i want? If yes, how do i implement the drag behavior for HwndHost?
Is there any other alternate solution i can try?
Note:
Although many consider MDI not an elegant solution, I do not have a choice. (We tried alternate solutions like tabbed windows/dockable
windows, but were not well received)
I am quite new to interop programming, and do not understand the
concepts well. Please correct me if i am misunderstanding things.
Thanks!

Image Control disapear after it's dragged in Design

I'm a WPF newbie and, unlike WinForms, I have a hard time to setup things in the design window.
My first obstacle is the Image control. After I drag it in the Design window it disappears and there's no way for me to edit its properties (like with the button control for example). The only way to make changes is via the XAML code which isn't very visual and intuitive.
Is there a way to keep editing the Image control in design mode? (example, move it around, select it to view its property panel, etc.)
All you should need to do is give the image control a fixed height and width and it should stay in the designer.
The best thing about the XAML is which separated from code for better re usability like asp.net. It's best you to learn different layouts such as grid, wrappanel, stackpanel etc. Then, you will feel the power of xaml. Else, you can choose the XAML building tools.
Link to refer

WPF UI detach(pin out) functionality

Am looking to implement a detach and popup UI behaviour in my applcation.
It basically means that I will be displaying say, a stackpanel with lot elements on the right side of my page. And on a button click, I want the stackpanel part to popup(removing its allocated space in the UI) and should be able to move it above the underlying wpf UI.
What am trying to do is that remove the stackpanel from its parent grid on button click and add it as the child of wpf popup control. But I am facing some issues doing this way. However I just want to know whether I am doing it in the correct way or do anyone have a good alternative for implementing this pin out functionality am specified here?
Thanks,
Vinsdeon
How about using this kinda nice control, AvalonDock, which is simulating Visual Studio's dockable components behaviors?
http://avalondock.codeplex.com/
It will spare you the pain of developing such a specific functionality, and will have a great reusability anyway

Have a wpf window inside another wpf window

Is there a way to host a WPF window inside another WPF window. I have a couple of somewhat complex forms in place. But now to simplify things I am trying to merge a few of them as tabpages inside one 'Dashboard' form.
Please note that I am not trying to host a Windows Form, but another WPF window
If you want tabpages, why not use a TabControl with UserControls inside ? If you need to transform one of these tabs to a floating window, just put the UserControl in a new Window...
Can I answer this question with another question; why would you not create them as controls rather than other WPF windows, that you want to host in the main WPF window?
a bit late on this, but I guess with WindowsForms interop you can put in WPF a WinForms control host and in that host put a WinForms control that hosts the handle of a WPF window
I think what you're asking for is MDI, Multiple Document Interface. Something like this might help.
Do note, however, that the MDI paradigm is largely shunned these days. There are usually better ways to achieve the same functionality.
I think you want to hosting contents of WPF Window1.xaml (page1.xaml) inside within another WPF Window.
Well...you can use Navigation. Instead running window1.xaml contents inside tab then you can work with your data inside Navigation. Navigation can run within WPF Window Application. You just design your form / UI in page1.xaml.
one another..MDI old and rusty. We want clear of top window nowadays.

VB6 ActiveX Control Inside WPF With Scrollbars

I have some legacy VB6, which I am hosting inside an ActiveX control, which is in my WPF application.
Despite putting the control inside of a DockPanel, which is inside a ScrollViewer, the VB6 displays outside the bounds of both, sitting on top of the rest of the application.
Does anyone know how I can keep the VB6 inside of the ScrollViewer without it spilling out onto the rest of the application?
ScrollViewer - expands to fill an area
Has a child element...
DockPanel - fixed to the height and width of the VB6 form
Has a child element...
VB6
Any help or guidance will be greatly appreciated.
I don't think you can do this, the ActiveX control is just going to sit on top of any XAML you wrap it in. As a workaround you could try creating a control in WinForms that contains your ActiveX control and handles the scrolling, then embed that in the WPF app. It's a bit hacky, and might be a pain if you need to resize, but it SHOULD work :-)

Resources