wpf 加载html页面,使用MVVM在WPF中显示HTML
我將
HTML-Source字符串保存在HTMLReport字段中稱為“Report”的sql Server表中(字段類型為NTEXT).現在我需要顯示存儲的HTML
進入WPF窗口.需要在此WPF窗口上解釋HTML標記和內聯CSS.
有人可以幫我完成這段代碼嗎?
HTMLView.xaml
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="HTML View" Height="454" Width="787"
>
HTMLviewmodel.cs
namespace MyProject
{
public class HTMLviewmodel: viewmodelBase
{
public HTMLviewmodel()
{
//Reading from sql Server table
//SELECT HTMLReport FROM Report WHERE ID=123
//OK,I have HTMLString from database over here
//Now I am assigning that to DisplayHTML Property
DisplayHTML ="
| This text should be in table with bold fond |
}
private string _displayHTML;
public string DisplayHTML
{
get
{
return _displayHTML;
}
set
{
if (_displayHTML!= value)
{
_displayHTML= value;
OnPropertyChanged("DisplayHTML");
}
}
}
}
總結
以上是生活随笔為你收集整理的wpf 加载html页面,使用MVVM在WPF中显示HTML的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 鸿蒙台湾乌龙茶,郭碧婷生女再闹乌龙?向太
- 下一篇: webstorm快捷键生成html页面,