我正在研究C#WPF项目,我遇到了RichTextBox语法更改颜色的问题。我想设计一些东西,当输入例如(if)时,程序改变所有(if)的颜色。
Window.xaml
$ knife upload /roles
Updated roles/dev_samba.json
Window.cs
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Background="#FF383838">
<TextBlock Name="LinsCountingArea" TextAlignment="Center" Margin="0,75,0,0" Foreground="White" FontSize="14" />
</Grid>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="75" />
<RowDefinition Height="*" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="#FFF3F3F3">
<TextBlock TextAlignment="Center" Padding="20" FontSize="24" Text="My Project" />
</Grid>
<Grid Grid.Row="1">
<RichTextBox Name="rtbEditor" FontSize="16" Padding="15" SelectionChanged="rtbEditor_SelectionChanged" TextChanged="rtbEditor_TextChanged"></RichTextBox>
</Grid>
<Grid Grid.Row="2" Background="WhiteSmoke">
<TextBox Name="txtStatus"/>
</Grid>
</Grid>
</Grid>
在您输入多个(如果)之前,它会很好。输入多于1(if或struct或while)后,程序会在特殊字词之前更改字符的颜色问题是什么?