RadRichTextBox copy&paste of a custom InlineUIContainer object

2 posts, 0 answers
  1. Michele
    Michele avatar
    2 posts
    Member since:
    Feb 2013

    Posted 20 Feb 2013 Link to this post

    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
  2. Michele
    Michele avatar
    2 posts
    Member since:
    Feb 2013

    Posted 22 Feb 2013 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top