RichTextBox可转换的格式如下:
格式 | Binary/Text | 支持格式 | 支持图形 |
Text | Text | No | No |
Rtf | Binary | Yes | Yes |
Xaml | Text | Yes | No |
XamlPackage | Binary | Yes | Yes |
TextRange t =
new
TextRange(richTextBox1.Document.ContentStart,
richTextBox1.Document.ContentEnd);
FileStream file =
new
FileStream(
"Sample File.xaml"
, FileMode.Create);
t.Save(file, System.Windows.DataFormats.XamlPackage);
file.Close();
TextRange t =
new
TextRange(richTextBox1.Document.ContentStart,
richTextBox1.Document.ContentEnd);
FileStream file =
new
FileStream(
"Sample File.xaml"
, FileMode.Open);
t.Load(file, System.Windows.DataFormats.XamlPackage);
file.Close();