Question

How to place text and Button in a same line in WPF Richtextbox?

In the image below some texts and a button control are placed in a richtextbox.

enter image description here

I want some texts to be placed before and after the button in the same line.

Is it possible to define some width to the blockuicontainer or a wayout to achieve the same?

What I want is:

enter image description here

Was it helpful?

Solution

I have added a FlowDocument to the RichTextBox and a Paragraph to the FlowDocument.

Sample code is:

Paragraph para = new Paragraph();
        FlowDocument fd = new FlowDocument();
        fd.Blocks.Add(para);
        txtExpression.Document = fd;
        para.Inlines.Add(new Button() { Content = "Hello!" });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top