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

Moving InLineUIContainer at runtime

5 Answers 142 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Colm
Top achievements
Rank 1
Colm asked on 11 Aug 2010, 11:01 AM
Hi,
I'm experimenting with using the richTextBox as a canvas for an applicaiton. The user will add controls like charts, grids etc at runtime and then position them on the page using the mouse.

I've written some code, using your examples, to add a chart to the canvas at load time. How would I be able to allow the user to move this element on the page at runtime?

Sample code:
public partial class MainPage : UserControl
   {
       public MainPage()
       {
           InitializeComponent();
           this.radRichTextBox1.IsReadOnly = true;
 
           RadDocument doc = new RadDocument();
           doc.LayoutMode = DocumentLayoutMode.Paged;
           doc.DefaultPageLayoutSettings = new PageLayoutSettings();
           doc.DefaultPageLayoutSettings.Height = 600;
           doc.DefaultPageLayoutSettings.Width = 500;
           Section section = new Section();
           doc.Sections.Add(section);
 
           Paragraph paragraph = new Paragraph();
           section.Paragraphs.Add(paragraph);
 
           Span span = new Span("Some Text before...");
           paragraph.Inlines.Add(span);
 
           Button button = new Button();
           button.Content = "Test Button";
           button.Width = 100;
           button.Height = 50;
 
           button.Click +=
               (s, a) =>
               {
                   MessageBox.Show("Your button was just clicked!");
               };
 
           RadChart radChart1 = new RadChart();
           radChart1.Width = 200;
           radChart1.Height = 200;
 
           InlineUIContainer container = new InlineUIContainer();
           container.UiElement = radChart1;
           container.Width = radChart1.Width;
           container.Height = radChart1.Height;
 
           paragraph.Inlines.Add(container);
 
           Span span2 = new Span("Some Text after...");
           paragraph.Inlines.Add(span2);
 
           this.radRichTextBox1.Document = doc;
       }
   }

5 Answers, 1 is accepted

Sort by
0
Ivailo Karamanolev
Telerik team
answered on 16 Aug 2010, 11:36 AM
Hello Colm,

As you will be inserting UI elements into the document, any keyboard and mouse events will be passed to that control and it should be handling them and acting accordingly. However, implementing drag&drop of these UI elements inside the document is a little bit tricky, as this is somewhat outside the intended use of RadRichTextBox as this feature is not supported out of the box..
If the main point of your scenario is the user to be able to move UI elements around the page with the mouse and/or keyboard, I'll advise you to take a different approach - maybe use an actual Canvas to contain the elements and not RadRichTextBox.
One thing you might have a look at is Telerik's own RadDragAndDropManager - that you can find the assembly Telerik.Windows.Controls - it might suit you as drag & drop helper.
Please get back to us if you need any further assistance.

Best wishes,
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
0
Colm
Top achievements
Rank 1
answered on 16 Aug 2010, 11:45 AM
Hi,
Yes, we also understood that the richtextbox wasn't designed for this purpose. We've written a text implementation using a canvas already but it's a little clunky. Ideally, we want to be able to use something similar to the VS2010 design surface within our application, but we're still looking for something to do this before we roll our own solution.

Under WinForms, we used to use the MS design surface directly. I wonder if there is something similiar for silverlight.
0
Accepted
Mike
Telerik team
answered on 16 Aug 2010, 12:11 PM
Hi Colm,

Unfortunately we are not aware of any Telerik or other third party control/tool that can help you in ths scenario. If you are trying to achieve designer-like functionality as far as understand the scenario the best approach would be to use canvas or a custom absolute positioning layout, RadDragAndDropManager we already mentioned, maybe Silverlight figures and other primitives and Telerik RadRichTextBox or other Input controls to help you achieve text rendering and text/editing functionality.

Best wishes,
Mike
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
0
Colm
Top achievements
Rank 1
answered on 16 Aug 2010, 12:28 PM
Yes, this is what we're currently doing. Hopefully we'll have a decent framework put together in the next month or two. Thanks for the help, much appreciated.
0
Mike
Telerik team
answered on 17 Aug 2010, 05:09 PM
Hello Colm,

We hope you will resolve all difficulties and will create a great app. Let us know if we can help with anything else.

Regards,
Mike
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
Colm
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Colm
Top achievements
Rank 1
Mike
Telerik team
Share this question
or