我想在我的表单上显示HTML部分。我在网上看了几个关于使用网络表单或文档布局等的例子,但没有什么对我有用。
我们的网站上有一个系统,用户可以使用真实文本编辑器(CKEditor)输入通知。消息保存在数据库中,办公室中所有计算机上的WPF应用程序都应显示消息。
我想在我的WPF程序中支持HTML。 HTML不在页面中,它是db中的一段HTML,需要在WPF应用程序上以其呈现的形式显示。
例如,如果有人输入<img src="http://www.google.com/google.jpg" />
,当我从数据库中检索并将其显示在表单上时,它将在wpf应用程序中显示该图像。
最好的方法是什么?
P.S。我无法使用Web浏览器,因为Windows将“AllowTranparency”设置为true。
答案 0 :(得分:6)
将WebBrowser控件添加到您的应用程序:
<Window x:Class="WpfBrowser.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WebBrowser Height="311" HorizontalAlignment="Left" Name="webBrowser1" VerticalAlignment="Top" Width="503" />
</Grid>
</Window>
然后使用NavigateToString
的{{1}}从您的html字符串加载页面:
WebBrowser