WPF web浏览器(3.5 SP1)总是在最上层 - 其他建议,在WPF显示HTML [英] WPF WebBrowser (3.5 SP1) Always on top - other suggestion to display HTML in WPF

查看:911
本文介绍了WPF web浏览器(3.5 SP1)总是在最上层 - 其他建议,在WPF显示HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在拼命寻找一种简单的方法在WPF应用程序中显示HTML。 有一些选择:
1)使用WPF WebBrowser控件
2)使用帧控制
3)使用第三方控件

I've been desperately looking for an easy way to display HTML in a WPF-application. There are some options:
1) use the WPF WebBrowser Control
2) use the Frame Control
3) use a third-party control

不过,我已经遇到了以下问题: 1)在WPF WebBrowser控件是不是真正的WPF(这是一个WinForms控制包裹在WPF)。我已经找到一种方法来创建一个包装,这和使用DependencyProperties导航到HTML文本绑定和的PropertyChanged。 这里的问题是,如果你把一个WinForms控制WPF ScrollViewer中,它不尊重的z-index,这意味着在WinForm总是在其他WPF控件的顶部。这很烦人,我试图解决它通过创建一个托管的ElemenHost等一的WindowsFormsHost ..但是这完全打破了我的约束力明显。

but, i've ran into the following problems: 1) the WPF WebBrowser Control is not real WPF (it is a Winforms control wrapped in WPF). I have found a way to create a wrapper for this and use DependencyProperties to navigate to HTML text with bindings and propertychanged. The problem with this is, if you put a Winforms control in WPF scrollviewer, it doesnt respect z-index, meaning the winform is always on top of other WPF control. This is very annoying, and I have tried to work around it by creating a WindowsFormsHost that hosts an ElemenHost etc.. but this completely breaks my binding obviously.

2)帧控制有同样的问题,显示如果它显示HTML内容。不是一种选择。

2) Frame Control has the same problems with displaying if it shows HTML content. Not an option.

3)我还没有找到一个本地的HTML显示为WPF。所有选项都的WinForms,并具有上述的问题。

3) I haven't found a native HTML-display for WPF. All options are winforms, and with the above mentioned problems.

唯一的出路我目前正在使用微软的越野车HtmlToXamlConverter,它崩溃有时很难。 ( MSDN

the only way out I have at the moment is using Microsoft's buggy HtmlToXamlConverter, which crashes hard sometimes. (MSDN)

是否有人对如何显示HTLM在WPF任何其他建议,如果没有这些问题?

Does anybody have any other suggestions on how to display HTLM in WPF, without these issues?

抱歉长的问题,希望有人知道我在说什么......

sorry for the long question, hope anyone knows what i'm talking about...

推荐答案

如果您不能使用web浏览器,你最好的选择是可能改写你的HTML内容转换为FlowDocument的(如果你使用静态的HTML内容)。

If you can't use WebBrowser, your best bet is to probably rewrite your HTML content into a FlowDocument (if you're using static HTML content).

另外,你提到,你有种有特殊情况的web浏览器,你是对的,它并没有像一个真正的WPF控件。你或许应该创建一个可以绑定到重新$ P $一个视图模型对象psents WebBrowser控件,您可以隐藏在一个地方所有的丑陋的非约束code,然后再也没有打开它:)

Otherwise, as you mention, you kind of have to special-case WebBrowser, you're right that it doesn't act like a "real" WPF control. You should probably create a ViewModel object that you can bind to that represents the WebBrowser control where you can hide all of the ugly non-binding code in one place, then never open it again :)

这篇关于WPF web浏览器(3.5 SP1)总是在最上层 - 其他建议,在WPF显示HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆