我可以使用 WPF WebBrowser 控件作为 C# 中的 UI 界面吗?
是否可以在 C# 中使用 WebBrowser 控件作为 UI 界面?
我喜欢将 HTML 字符串直接写入控件中,并在单击此类链接时获取事件并读取超链接的值。 HTML 是一种很棒的渲染语言,如果我们不能在应用程序中使用这项技术似乎是一种浪费。
如果这不可能,是否有任何好的替代方案,因为 WPF 控件不够“流畅”。 我需要一个非常灵活的渲染环境,但不喜欢重新发明轮子。
我想澄清的是,我当然可以包含这样的控件并使用 HPPT 或其他协议获取和发送数据,但就我而言,我想直接分配 HTML 字符串并捕获超链接事件的点击。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 WindowsFormHost 中托管任何 Windows 窗体控件 (您可能会在工具箱中找到它。
但是,FlowDocument 可能更合适对于这样的事情,因为它是真正的WPF,所以它可以是任何控件的内容。
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.
您可以使用 WebBrowser 控件来呈现应用程序的 UI。 我建议不要这么做。 控件的版本可能会影响应用程序的呈现方式,并且维护 UI 中使用的所有资源(html、图片、javascript?)会很麻烦。
请阅读有关 WPF 的更多内容,Expression Blend 3 刚刚发布,您可以用它制作一个很棒的用户界面。 为了保持流畅,不要对透明度之类的东西太着迷,它会减慢加载时间。 WPF 是一种更加面向未来的技术。
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.