如何复制 WPF FlowDocument InlineUIContainer 内容?
我有一个 WPF FlowDocument,其中有一些 InlineUIContainer,这些是简单的 InlineUIContainer,其中包含一个样式化按钮,其中 Button.Content 中包含一些文本。当我将包含按钮的文本和 InlineUIContainer 从 FlowDocument 复制到 TextBox 时,不会复制该按钮。
可以以某种方式转换内联按钮或将按钮转换为粘贴的文本数据中的文本。我尝试过使用 FlowDocument.DataObject.Copying 事件,但我似乎找不到任何关于如何使用它的好示例,或者即使这是正确的方向。
谢谢
I have a WPF FlowDocument that has a few InlineUIContainers, these are simple InlineUIContainers, that contain a styled button with some text in the Button.Content. When I copy the text and InlineUIContainer containing the button from the FlowDocument to a TextBox, the button is not copied.
It is possible to somehow convert the inline button or convert the button to text in the pasted text data. I have tried using the FlowDocument.DataObject.Copying event, but I can't seem to find any good samples on how to use this or even if this is the right direction.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的问题,并设法得到类似以下内容的工作:
当然,这非常简单 - 您可能会创建 Button 的子类并定义一个像“GetCopyToClipboardText”这样的接口函数,而不是“如何获取文本”来自按钮”-richtextbox 内的代码。
该示例复制了 richtextbox 内的所有文本 - 如果仅将文本框的选定部分复制到剪贴板,则会更有用。 这篇文章给出了如何实现这一目标的示例。
I had the same problem and managed to get something like the following to work:
Of course this is very simplistic - you would probably create a subclass of Button and define an interface-function like "GetCopyToClipboardText" instead of having the "how to get text from a button"-code inside the richtextbox.
The example copies all text inside the richtextbox - it would be more usefull if only the selected part of the textbox was copied to the clipboard. This post gives an example of how to achive that.