Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有xaml或rtf到c#wpf richtextbox的字符串_C#_Wpf_String_Xaml_Rtf - Fatal编程技术网

带有xaml或rtf到c#wpf richtextbox的字符串

带有xaml或rtf到c#wpf richtextbox的字符串,c#,wpf,string,xaml,rtf,C#,Wpf,String,Xaml,Rtf,我得到了一个带有xaml或rtf的字符串,我想知道如何在c#wpf richtextbox中获取它 这两个字符串如下所示,希望使用其中一个字符串 string xaml = "<FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph>HOOFDDORP - Het zou helemaal niet n

我得到了一个带有xaml或rtf的字符串,我想知道如何在c#wpf richtextbox中获取它

这两个字符串如下所示,希望使用其中一个字符串

   string xaml = "<FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph>HOOFDDORP - Het zou helemaal niet noodzakelijk zijn voor <Run FontStyle="italic">SimCity </Run>om altijd met het internet verbonden te zijn, omdat er geen simulatie op de servers plaatsvindt. </Paragraph></FlowDocument>"

   string rtf = "{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf0 \cf0\ql{\f2 {\ltrch HOOFDDORP - Het zou helemaal niet noodzakelijk zijn voor }{\i\ltrch SimCity }{\ltrch om altijd met het internet verbonden te zijn, omdat er geen simulatie op de servers plaatsvindt. }\li0\ri0\sa0\sb0\fi0\ql\par}}}"
string xaml=“HOOFDDORP-zou helemaal niet noodzakelijk zijn voor SimCity om altijd在互联网上遇到了更多的问题,在服务器平台上模拟操作。”
字符串rtf=“{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}}{\colortbl\red0\green0\BLUEN0;\red255\green255\BLUEN255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf0\cf0\cf0\ql{\f2\ltrch HOOFDDORP\Het-ZHOODORK\Het ZHOODORK\BLUEN255\BLUEN255}{\ltrch om altijd遇到了internet详细信息,omdat er geen simulatie op de servers plaatsvindt.}\li0\ri0\sa0\sb0\fi0\ql\par}”
使用
populateRTF(rtf)

此外,还需要转义RTF字符串:

string rtf = @"{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf0 \cf0\ql{\f2 {\ltrch HOOFDDORP - Het zou helemaal niet noodzakelijk zijn voor }{\i\ltrch SimCity }{\ltrch om altijd met het internet verbonden te zijn, omdat er geen simulatie op de servers plaatsvindt. }\li0\ri0\sa0\sb0\fi0\ql\par}}}"
您可以使用:

  string content = "";
  textBox.Document.SetText(TextSetOptions.FormatRtf, content);

我的richtextbox没有Selection.Load();它是在wpfIt should中创建的richtextbox,Ok最终修复了,感谢您的帮助。可能的重复项
  string content = "";
  textBox.Document.SetText(TextSetOptions.FormatRtf, content);