Displaying HTML in WPF using MVVM

后端 未结 3 1547
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 02:43

I have HTML-Source string saved in SQL Server table called \"Report\" in HTMLReport field (field type is NTEXT). Now I need to display that stored HTML into WPF Window. HT

3条回答
  •  悲&欢浪女
    2021-01-12 03:16

    I would recommend to use Exceed WPF ToolKit RichTextBox which can bind to string representation of Xaml markup using Text property. For converting Html to Xaml I used HtmlToXamlConverter nuget package. HtmlToXamlConverter.ConvertHtmlToXaml(html, false)

    If you want to display it as TextBlock as me here are some styles:

    Style TargetType="RichTextBox" x:Key="RichTextBoxStyle">
            
            
            
            
            
            
        
    
        
    

提交回复
热议问题