html如何载入xaml文件,将HTML读取到XAML TextBlock中

I have a webform where users are submitting articles that contain bold text, italics text, links, images, etc. It is being stored into nvarchar(MAX) data type.

I am able to pull the information in the same format as it was submitted on a web site (ASP.NET & C#), this is how I do that:

ASP.NET

C#

//inserting data into DB

//getting data from DB

//assigning text I got to div

body.InnerHtml = rdr.GetSqlString(rdr.GetOrdinal("Body"));

My problem is, that the article being submitted into the DB is being submitted in this type of format:

This is bold text. This is italics text. This is normal text. This is a link 

Basically it is being submitted in markup - which is fine, but I have one problem. I am trying to pull this information into a TextBlock inside of my Windows 10 application (Universal Web Application), but it is coming in as HTML and TextBlock is XAML and I feel like it is not going to mesh well...

This is my XAML:

RelativePanel.Below="myViews"

RelativePanel.AlignLeftWithPanel="True"

RelativePanel.AlignRightWithPanel="True"

LineHeight="24"

TextWrapping="Wrap"

Foreground="Black"

Margin="0,20,0,20"/>

C#

myBody.Text = retrievedHTMLBody;

My question is, is how can I display the information (same format that it was submitted in on the web form) in the TextBlock the same way that it is displaying in my DIV? I do not have a problem pulling the data in, but it is setting the textblock text to the format(bold, italics, links, etc.) the same way I am able to set it in my DIV that is throwing me for a loop...

Talk1:

You're looking for RichTextBox/Block. Might give a peek at something like this before you go too far down the rabbit hole. There's others also but I don't remember any of them, haven't done this in some time.

Talk2:

What is the easiest way to plug that line of markup I included into the RichTextBlock to see if it is interpreting it correctly?

Talk3:

And that way looks really extensive... This has had to of been done before....

Talk4:

. Ended up finding a solution, thank you for your input again

Solutions1

I ended up finding a solution. It is to use a Webview and bind the HTML to it using NavigateToString

XAML

C#

string htmContent = @"your html goes here";

myWebView.NavigateToString(htmContent);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值