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

How to interact with DocumentPanes?

1 Answer 101 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 15 May 2012, 01:00 AM
Good evening,

This may be a bit of a noob question but how does one interact with RadDocumentPane from a main window?

Let me detail my Situation.

My main window contains a RadDockingControl. The RadDockingControl has an area for a DocumentHost.
<telerikDocking:RadDocking.DocumentHost>
    <telerikDocking:RadSplitContainer>
        <telerikDocking:RadPaneGroup x:Name="radDockingDocumentHost" />
    </telerikDocking:RadSplitContainer>
</telerikDocking:RadDocking.DocumentHost>

In Code Behind I programmatically add RadDocumentPanes to the DocumentHost whenever a button is pressed.
private void btnBlankNewOrder_Click(object sender, RoutedEventArgs e)
{
    //ADD NEW DOCUMENT PANE _ RadRichTextBox
    var pane = new RadRichTextBoxAutoComplete(products);
    pane.Title = "Rob's Test Pane";
    radDockingDocumentHost.Items.Add(pane);
}

The RadDocumentPanes being added are a modified UseControl which now inherits the RadDocumentPane.
<telerik:RadDocumentPane x:Class="TAS2.RadRichTextBoxAutoComplete"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:telerikDocking="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking"
             xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             mc:Ignorable="d">
 
.................MY CONTROL CONTENT HERE (Cut Out for this Example) ...................
 
</telerik:RadDocumentPane>

Each RadDocumentPane hosts a Grid (actually there are nested Grids which have been cut out for this example) that contain a RadRichTextBox.
<telerik:RadDocumentPane x:Class="TAS2.RadRichTextBoxAutoComplete" ..... >
          <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                 
                <!-- RichTextBox -->
                <telerik:RadRichTextBox x:Name="radRichTextBox" AcceptsReturn="True" Width="800" Margin="10" Padding="10" Grid.Column="0"
                                        FontSize="14" IsSpellCheckingEnabled="False" DocumentInheritsDefaultStyleSettings="True" />
          </Grid>
</telerik:RadDocumentPane>

Going back to my Main Window that contains the main RadDocking control, I have a Ribbon menu containing several buttons (see the attached image).

How do I interact with the programatically added RadDocumentPanes and their respective RichTextBox's when pressing a button in the Ribbon menu?

For example, suppose that the ribbon bar contains a "Paste" button. How do I make the "Paste" command associate itself with the RichTextBox of the current DocumentPane in view?

I would attach samples of my code but it won't let me add them, only images.

Thank you for your time,

All help is appreciated.

1 Answer, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 15 May 2012, 01:41 AM
Ok ok I spoke a bit too soon. I managed to work it out after stumbling across a little example in the documentation.

Here's the code:

//******* TEST BUTTON TO INTERACT WITH DOCUMENTPANE RTB **********
private void btnPasteTest_Click(object sender, RoutedEventArgs e)
{
    var currentPane = radDockingDocumentHost.SelectedPane;
 
    if (currentPane is RadRichTextBoxAutoComplete)
    {
        ((RadRichTextBoxAutoComplete)currentPane).radRichTextBox.Insert("Hello");
    }
}
Tags
Docking
Asked by
Robert
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Share this question
or