views:

440

answers:

2

Is it possible to use the WebBrowser control as a UI interface in C#?

I like to write a string of HTML directly into the control and get an event and read the value of the hyperlinks when such a link is clicked. HTML is a great rendering language and it seems to be a waste if we could not use this technology in applications.

If this is not possible are there any good alternatives, as the WPF controls are not 'fluid' enough. I require a very flexible rendering environment but prefer not to reinvent the wheel.

I like to clarify that of course I can include such a control and get and send data using HPPT or other protocols but in my case I want to directly assign a string of HTML and capture the click on hyperlink events.

+1  A: 

You can host any Windows Forms control in a WindowsFormHost (you'll probably find it in the toolbox.

However, FlowDocument maybe more suitable for such things, as it's truly WPF, so it can be the content of any control.

Tamás Szelei
I wouldn't start off a new program based on a WinForms-WPF mix. From what I've heard the WindowsFormHost was mainly intended for migrating applications to WPF, not for new software.
Zyphrax
That's true. This is why I suggested FlowDocument.
Tamás Szelei
+1  A: 

You could use the WebBrowser control to render your application's UI. I would advise against it. Versions of the controls could influence the way your application renders and it's going to be a hasle to mantain all the resources used in the UI (html, pics, javascript?)

Read a bit more on WPF, Expression Blend 3 was just released and you can make an awesome UI with it. To keep it fluid don't go crazy on things like transparency, it slows down loading times. WPF is a far more future proof technique.

Zyphrax