简体   繁体   English

我可以在Silverlight 4中的RichTextBox中放置一个按钮吗?

[英]Can I put a Button in a RichTextBox in Silverlight 4?

I would like to allow users to put a System.Windows.Controls.Button in the System.Windows.Controls.RichTextBox. 我想允许用户将System.Windows.Controls.Button放在System.Windows.Controls.RichTextBox中。 The button would do a pre-defined thing. 该按钮将执行预定义的操作。

I figured out how to do this. 我想出了怎么做。 It's called an InlineUIContainer you can do something like this to get it working. 它称为InlineUIContainer,您可以执行以下操作使其正常工作。 Although it doesn't save it into the Xaml 尽管它不会将其保存到Xaml中

var p = new Paragraph();
var inlineUIContainer = new InlineUIContainer() { Child = new Button() { Content = "This is a Button!" } };
p.Inlines.Add(inlineUIContainer);
_richTextBox.Blocks.Add(p);

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

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