MaKui

博客园 首页 新随笔 联系 订阅 管理
 

客户希望系统在一些特定的条件下,界面上能显示用户自定义的格式和内容,格式和内容通过html指定。

 

基本上在wpf中显示html有以下四种方法。

1.       Wpf Frame control

this.frame1.Navigate(uri);

this.frame1.Source = uri;

 

无法直接指定html内容。

 

2.       Wpf WebBrowser control

this.webBrowser1.Navigate(source);

this.webBrowser1.NavigateToStream(stream);

this.webBrowser1.NavigateToString(html);

this.webBrowser1.Source = uri;

 

NavigateToString可直接处理html内容的字符串,但不幸是方法而不是属性。

 

3.       使用Winform的webBrowser control

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/feab32d0-2d50-43e0-939a-7b20db7a4b54/

winform的webBrowser还是比较好用的,但是在wpf下需要引用System.Windows.Forms.dll and WindowsFormsIntegration.dll。

 

4.       将html转换成FlowDocument

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/9f0611de-9e7c-4a67-bc07-406844413e48/

这种办法太麻烦了

 

以上这4种方法都无法在xaml中直接处理,看来,如果仅仅是为了让用户能自定义界面,还是用自定义template的方法比较合适。

posted on 2011-08-02 16:35  MaKui  阅读(6566)  评论(1编辑  收藏  举报