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

RadRichTextBox copy&paste of a custom InlineUIContainer object

1 Answer 145 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 1
Michele asked on 20 Feb 2013, 11:59 AM
Hi,
I'd like to know how I can use the copy and paste on objects of type custom using InlineUIContainer class.
I did some tests, but I could not duplicate the object, also using an override CopyableInlineUIContainer with the functions CopyPropertiesFromOverride/CopyContentFromOverride.

The object of type InlineUIContainer contains a control RadButton whose content is an image. I also linked to the button RadButton an event MouseDoubleClick to show custom dialog box.

This is a sample code:

string controlName = "PLACEHOLDER_" + getNewId();   // ex. PLACEHOLDER_1
string controlTag = getNewTag();    // ex. 100231
var button = new RadButton
{
     Name = controlName,
     Tag = controlTag,      // this tag is used to retrieve custom properties from database
     Width = 100,
     Height = 32,
};
 
// add the image to content
button.Content = this.getCustomUIElementByPlaceholder(message, controlName);
button.MouseDoubleClick += SelectPlaceHolder;       // event fired when user doubleclick the button
 
// create the UI element
// new class with copyable=true override
var container = new CopyableInlineUIContainer { UiElement = button, Width = button.Width, Height = button.Height, Tag = controlName };
// original code
// var container = new InlineUIContainer { UiElement = button, Width = button.Width, Height = button.Height, Tag = controlName };
 
// invoke the insert method
// Note: editor if a WPF control of type RadRichTextBox
editor.InsertInline(container);
 
// add a text coomment
string sContentComment = "Custom placeholder NAME " + controlName + " TAG " + controlTag;
var comment = new Comment(sContentComment) { Name = string.Concat("m", controlTag) };
editor.ShowComments = true;
 
var startPosition = editor.Document.CaretPosition;
var endPosition = new DocumentPosition(startPosition);
startPosition.MoveToCurrentWordStart();
endPosition.MoveToCurrentWordEnd();
 
editor.Document.Selection.AddSelectionStart(startPosition);
editor.Document.Selection.AddSelectionEnd(endPosition);
editor.Document.InsertComment(startPosition, endPosition, comment);


If I try to duplicate the object, only the comment is actually copied.

Is there any solution for this?

Thanks,
Michele Fochi

1 Answer, 1 is accepted

Sort by
0
Michele
Top achievements
Rank 1
answered on 22 Feb 2013, 05:31 PM
I have already received the answer of my question: it's not possible make a copy of an InlineUIContainer.
Please remove this thred.

Thanks
Michele
Tags
RichTextBox
Asked by
Michele
Top achievements
Rank 1
Answers by
Michele
Top achievements
Rank 1
Share this question
or