简体   繁体   English

富文本框模板

[英]Templates for Rich Text Box

I have a rich text box which allows users to input text. 我有一个富文本框,允许用户输入文本。 What I want is some predefined sentences (which can't be edited) that can be dragged into the Rich text box. 我想要的是一些预定义的句子(无法编辑),可以将其拖到Rich文本框中。 Does anyone know of a way that this can be done. 有谁知道可以做到这一点的方法。

This is a WPF application so im using XAML. 这是一个WPF应用程序,因此我正在使用XAML。

Enable AllowDrop on your RichTextBox and capture the Drop event (or it might be PreviewDrop on RTB). RichTextBox上启用AllowDrop并捕获Drop事件(或者在RTB上可能是PreviewDrop )。

You can then do whatever you want with it. 然后,您可以随心所欲地做任何事情。 Such as creating a Label that allows you to drag it into the RTB. 例如创建允许您将其拖到实时出价工具中的标签。

Drag/Drop in WPF is covered here on MSDN . WSDN中的拖放功能在MSDN上已介绍

What Rudi said but also, if you are looking to have the sentences visually dragged, as slightly transparent blocks of text, then you need to look into specifying an Adorner during the drag and drop process. Rudi所说的话,但是,如果您希望将句子可视化地拖动,作为稍微透明的文本块,那么您需要在拖放过程中考虑指定Adorner。 There is a good example here . 有一个很好的例子在这里 The example is ListView-specific but could be quite easily customised for your rich text box. 该示例是特定于ListView的,但可以很容易地针对您的富文本框进行自定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM