4

我正在开发记事本克隆。我想在文本板(垂直选择)中实现块选择。我该怎么做?

文本板块选择

编辑:我不知道应该在这个问题中添加什么样的细节。然而,这是我的代码。我需要在此文本框中添加块选择功能。

<TextBox Name="txtContentBox"
         Text="{Binding Content, UpdateSourceTrigger=PropertyChanged}"
         VerticalAlignment="Stretch"
         Background="White"
         Foreground="#111111"
         BorderThickness="0"
         FontSize="{Binding FontSize}"
         FontFamily="{Binding CurrentFont}"
         FontStyle="{Binding IsItalic, Converter={StaticResource BoolToFontStyle}, ConverterParameter=Italic}"
         FontWeight="{Binding IsBold, Converter={StaticResource BoolToFontWeight}, ConverterParameter=Bold}"
         TextWrapping="{Binding IsWrap, Converter={StaticResource BoolToWrap}}"                                                          
         SelectionBrush="#6674AAE2"                             
         AcceptsReturn="True"
         AcceptsTab="True"
         VerticalScrollBarVisibility="Auto"
         HorizontalScrollBarVisibility="Auto"                             
         AllowDrop="True"
         SnapsToDevicePixels="False"
         MouseMove="txtContentBox_MouseMove"
         PreviewMouseDown="txtContentBox_PreviewMouseDown"
         PreviewMouseUp="txtContentBox_PreviewMouseUp">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="TextChanged">
            <cmd:EventToCommand Command="{Binding HandleChangesCommand}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="PreviewMouseWheel">
            <cmd:EventToCommand Command="{Binding IncDecFontSizeCommand}"
                                PassEventArgsToCommand="True" />
        </i:EventTrigger>
        <i:EventTrigger EventName="Drop">
            <cmd:EventToCommand Command="{Binding OpenCommand}"
                                PassEventArgsToCommand="True" />
        </i:EventTrigger>
        <i:EventTrigger EventName="PreviewDragEnter">
            <cmd:EventToCommand Command="{Binding PreviewDraggedFileCommand}"
                                PassEventArgsToCommand="True" />
        </i:EventTrigger>
        <i:EventTrigger EventName="PreviewDragOver">
            <cmd:EventToCommand Command="{Binding PreviewDraggedFileCommand}"
                                PassEventArgsToCommand="True" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</TextBox>
4

1 回答 1

3

您可以使用AvalonEdit。它是一个原生 WPF 编辑器,具有此功能等等。

于 2012-06-05T08:56:33.230 回答