1

So, here is my issue, im working in a Wpf application, so i dont have all of the standard windows form controls.. so im attempting to use a windowsformshost, to hold a webbrowser inside of a tabitem. So here is what i have:

        Tab t = new Tab();
        Browser newbrowse = new Browser(t);
        WindowsFormsHost host = new WindowsFormsHost();
        Grid g = new Grid();

        host.Child = newbrowse;
        newbrowse.Dock = DockStyle.Fill;
        g.Children.Add(host);

        t.Header = "New Tab";
        t.Content = g;
        tabControl1.Items.Add(t);

now, Tab, and Browser, are just my custom implementations of the controls, and they both are tested and working. So that is not the issue. Now as far as i can see, that code should work. But I'm left staring at a blank tab page. Note that this will need to be in the codebehind and cant be included in the WPF itself.

Thanks for any input! :) Cheers

EDIT: Note that i have also tried the operation with the standard, controls.tabitem, and forms.webbrowser to the same effect

2
  • You know that there's a WPF WebBrowser control? It was added in 3.5 SP1. It backs onto the same ActiveX control as the WinForms one, but saves you having to muck around with WindowsFormsHost. Commented Jan 10, 2010 at 20:30
  • I must not have the SP, if i dont get an answer in a reasonable amount of time, i may consider upgrading. But if i can find a suitable method this way, I'd like to stick with my current setup Commented Jan 10, 2010 at 20:33

1 Answer 1

2

I just tried this, and apparently what breaks your plan is the line:

newbrowse.Dock = DockStyle.Fill;

Comment it out, and watch how it suddenly works!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.