This is a migrated thread and some comments may be shown as answers.

InlineUIContainer : How to update the width and Height

1 Answer 256 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 28 Jun 2011, 02:16 PM
Hi,

These lines of code create a new InlineUIContainer, with a button with the size 30X30 :

            Telerik.Windows.Documents.Model.InlineUIContainer container = new Telerik.Windows.Documents.Model.InlineUIContainer();
            CustomButton button = new CustomButton();
            container.UiElement = button;
            container.Width = 30;
            container.Height = 30;
            this.radRichTextBox.InsertInline(container);
            radRichTextBox.UpdateEditorLayout();

But, let's say i made a mistake. Just after the UpdateEditorLayout, let's say i want to change again the width and Height :

            Telerik.Windows.Documents.Model.InlineUIContainer container = new Telerik.Windows.Documents.Model.InlineUIContainer();
            CustomButton button = new CustomButton();
            container.UiElement = button;
            container.Width = 30;
            container.Height = 30;
            this.radRichTextBox.InsertInline(container);
            radRichTextBox.UpdateEditorLayout();

            container.Width = 130;
            container.Height = 130;
            radRichTextBox.UpdateEditorLayout();

For some strange reason, in the editor, the size of my container is still 30X30... Once you setup the width and height, on creation, is there any way to change it later on?

Best regards,

1 Answer, 1 is accepted

Sort by
0
Ivailo Karamanolev
Telerik team
answered on 01 Jul 2011, 03:27 PM
Hi Patrick,

InsertInline actually inserts a copy of the DocumentElement you pass it, so the InlineUIContainer you're modifying is not the one inside the document. You can use the following code snippet to obtain the InlineUIContainer that is in the RadDocument after you call InsertInline:
InlineUIContainer container = new InlineUIContainer(new Button(), new Size(40, 40));
document.InsertInline(container);
InlineUIContainer insertedContainer = ((UIElementLayoutBox)document.CaretPosition.GetPreviousInlineBox()).AssociatedUIElementInline;
insertedContainer.Width = 100;
insertedContainer.Height = 100;
Let us know if you need additional assistance.

All the best,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
RichTextBox
Asked by
Patrick
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Share this question
or