RichTextBox for WPF
手順1:WPF アプリケーションの作成
クイックスタート > 手順1:WPF アプリケーションの作成

The below section gets you started with RichTextBox control in .NET and .NET Framework versions.

In this step, you create a new WPF application and add the RichTextBox and RichTextBoxToolbar controls in XAML. After completing this step, you have a mostly functional text-rich editor.

In Design View

To add the RichTextBox control to your WPF application in Design view, perform the following steps

  1. Create a new WPF application in Visual Studio.
  2. Navigate to the Toolbox and locate the C1RichTextBox and C1RichTextBoxToolbar controls.
  3. Double-click the C1RichTextBox and C1RichTextBoxToolbar icons to add the controls to the MainWindow.
  4. In the XAML view, add the relevant namespaces to the page by editing the MainWindow tags.
    XAML
    コードのコピー
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" x:Class="RTBQuickStart.MainWindow"
    Title="MainWindow" Height="350" Width="525">
    
  5. Place the cursor between the <Grid> and </Grid> tags, click once, and add the following markup within the <Grid> tags to add a StackPanel panel.
    XAML
    コードのコピー
    <StackPanel HorizontalAlignment="Left" Margin="0,10,0,0" x:Name="SP" VerticalAlignment="Top" Height="418" Width="645" Grid.ColumnSpan="2" Grid.Column="1"/>
    
         
  6. Click between the StackPanel tags and add the following markup to edit the appearance and positioning of RichTextBox and RichTextBoxToolbar controls in the XAML view.
    XAML
    コードのコピー
    <c1:C1RichTextBox Name="c1RichTextBox1" Margin="0,127,0,10"/>
    <c1:C1RichTextBoxToolbar RichTextBox="{Binding ElementName= c1RichTextBox1}" Name="C1RTBTB" Margin="3,0,-3,197" />
    
       

On running the application, you see an almost fully functional RichTextBox application. You can enter text in the RichTextBox control and edit the text using the options in the RichTextBoxToolbar. In the next step, you set up spell-checking and customize the application further.

In this step, you create a new WPF core application and add the RichTextBox control in XAML. After completing this step, you have a mostly functional text-rich editor.

In Design View

To add the RichTextBox control to your WPF core application in Design view, perform the following steps

  1. Create a new WPF core application in Visual Studio.
  2. Navigate to the Toolbox and locate the C1RichTextBox control.
  3. Double-click the C1RichTextBox icon to add the controls to the MainWindow.
  4. In the XAML view, add the relevant namespaces to the page by editing the MainWindow tags.
    XAML
    コードのコピー
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" x:Class="RTBQuickStart.MainWindow"
    Title="MainWindow" Height="350" Width="525">
    
  5. Place the cursor between the <Grid> and </Grid> tags, click once, and add the following markup within the <Grid> tags to add a StackPanel panel.
    XAML
    コードのコピー
    <StackPanel HorizontalAlignment="Left" Margin="0,10,0,0" x:Name="SP" VerticalAlignment="Top" Height="418" Width="645" Grid.ColumnSpan="2" Grid.Column="1"/>
    
         
  6. Click between the StackPanel tags and add the following markup to edit the appearance and positioning of RichTextBox control in the XAML view.
    XAML
    コードのコピー
    <c1:C1RichTextBox Name="c1RichTextBox1" Margin="0,127,0,10"/>
    
       

On running the application, you see an almost fully functional RichTextBox application. You can enter text in the RichTextBox control and edit the text using the options. To know more about the available editing features in .NET RichTextBox, browse through the respective feature topics.