本文整理汇总了C#中System.Windows.Controls.RichTextBox类的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox类的具体用法?C# RichTextBox怎么用?C# RichTextBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RichTextBox类属于System.Windows.Controls命名空间,在下文中一共展示了RichTextBox类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RichTextBoxExample
//引入命名空间
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Documents;
namespace SDKSample
{
public partial class RichTextBoxExample : Page
{
public RichTextBoxExample()
{
StackPanel myStackPanel = new StackPanel();
// Create a FlowDocument to contain content for the RichTextBox.
FlowDocument myFlowDoc = new FlowDocument();
// Add paragraphs to the FlowDocument.
myFlowDoc.Blocks.Add(new Paragraph(new Run("Paragraph 1")));
myFlowDoc.Blocks.Add(new Paragraph(new Run("Paragraph 2")));
myFlowDoc.Blocks.Add(new Paragraph(new Run("Paragraph 3")));
RichTextBox myRichTextBox = new RichTextBox();
// Add initial content to the RichTextBox.
myRichTextBox.Document = myFlowDoc;
myStackPanel.Children.Add(myRichTextBox);
this.Content = myStackPanel;
}
}
}