WPF RichTextBox中的C#TextBlock拖放操作 [英] C# TextBlock drag and drop operation in WPF RichTextBox

查看:60
本文介绍了WPF RichTextBox中的C#TextBlock拖放操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请提供以下帮助:在我的WinForm中,我有一个WPF RichTextBox,其中的Paragraph(仅使用一个Paragraph块)可能包含一个或多个TextBlock.当我尝试将任何TextBlock拖放到同一RichTextBox中的其他位置时,它在源位置消失,但没有插入目标位置.而是仅插入一个空格.我不知道在哪里搜索.大多数主题专门讨论不同控件之间的拖放操作,而不是同一控件中的操作.

Please help with the following: In my WinForm, I have a WPF RichTextBox in which Paragraph (only one Paragraph block is used) may contain one or several TextBlock''s. When I try to drag-n-drop any TextBlock to a different location within the same RichTextBox, it disappears at the source location but is not inserted at the target location. Instead just a space is inserted. I have no idea where to search. Most topics are dedicated to drap-n-drop operations between different controls, not within the same one.

<UserControl x:Class="TetranTranslationStudio.MyRichTextBox"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="162.711" Width="559.944" AllowDrop="False">
    <RichTextBox x:Name ="TargetBox" AcceptsReturn="False" SpellCheck.IsEnabled="True" Height="Auto" Width="Auto" VerticalScrollBarVisibility="Auto" IsDocumentEnabled="True" FontSize="14" FontFamily="Arial" AllowDrop="True">
        <FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ColumnWidth="400" FontSize="14" FontFamily="Arial" AllowDrop="True">
                        <Paragraph>This is a sample string which contains
                    <TextBlock>TextBlocks</TextBlock> that disappear when drags to a different location within the control
            </Paragraph>
        </FlowDocument>
    </RichTextBox>
</UserControl>



非常感谢您的帮助.

Vitaly



I will very much appreciate any help.

Vitaly

推荐答案

看看嵌入的自定义GUI在WPF中 [^ ]

本文介绍了如何处理拖放,剪切和粘贴,反序列化和打印.

最好的问候
Espen Harlinn
Have a look at Embed Custom GUIs in WPF[^]

The article shows how to handle drag-and-drop, cut-and-paste, deserialization, and printing.

Best regards
Espen Harlinn


这篇关于WPF RichTextBox中的C#TextBlock拖放操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆