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

ManageStylesDialog Opens Behind RadRichTextBox in Child Window

6 Answers 58 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 11 Mar 2013, 05:00 PM
I have a RadRichTextBox with the ribbon control in a modeless ChildWindow. If I click the Change Styles button the ManageStylesDialog opens behind the editors ChildWindow. Is there a way to ensure the ManageStylesDialog initially appears on top of the editors ChildWindow?

6 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 14 Mar 2013, 01:25 PM
Hello John,

Thank you for your question.

To ensure that the ManageStylesDialog appears in front of your ChildWindow you could keep an instance of it in the code behind of the page and when the ShowManageStylesDialogCommand is executed to call BringToFront() method of this instance. The following code demonstrates this approach:

public ChildWindowControl()
{
    InitializeComponent();
 
    this.manageStylesDialog = this.editor.ManageStylesDialog as ManageStylesDialog;
    this.editor.CommandExecuted += editor_CommandExecuted;
}
 
ManageStylesDialog manageStylesDialog;
void editor_CommandExecuted(object sender, CommandExecutedEventArgs e)
{
    if (e.Command is ShowManageStylesDialogCommand)
    {
        Dispatcher.BeginInvoke(() =>
            {
                this.manageStylesDialog.BringToFront();
            });
    }
}

Have in mind that the following dialogs are also non-modal and you could adopt the same approach with them: FindReplaceDialog, RadInsertSymbolDialog and InsertCrossReferenceWindow.

I hope this helps. Please, do not hesitate to contact us if you have any other questions.


Greetings,
Vasil
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Lucien
Top achievements
Rank 1
answered on 04 Jun 2013, 04:40 AM
Hi Vasil,

I have exactly the same problem and have tried your solution (created a reference to the dialog windows in the code behind and subscibed to the CommandExecuted event to bring the dialog windows to the front - see below), but the dialog windows still open behind my current window. Do you have any other suggestions?

Thanks in advance,

Lucien Dol

public partial class TemplateEditorView
{
    private readonly ManageStylesDialog _stylesDialog;
    private readonly FindReplaceDialog _findReplaceDialog;
    private readonly RadInsertSymbolDialog _insertSymbolDialog;
    private readonly RadParagraphPropertiesDialog _paragraphPropertiesDialog;
 
    public TemplateEditorView()
    {
        InitializeComponent();
 
        _stylesDialog = TemplateRadRichTextBox.ManageStylesDialog as ManageStylesDialog;
        _findReplaceDialog = TemplateRadRichTextBox.FindReplaceDialog as FindReplaceDialog;
        _insertSymbolDialog = TemplateRadRichTextBox.InsertSymbolWindow as RadInsertSymbolDialog;
        _paragraphPropertiesDialog = TemplateRadRichTextBox.ParagraphPropertiesDialog as RadParagraphPropertiesDialog;
             
        TemplateRadRichTextBox.CommandExecuted += TemplateRadRichTextBoxOnCommandExecuted;
    }
 
    private void TemplateRadRichTextBoxOnCommandExecuted(object sender, CommandExecutedEventArgs e)
    {
        if (e.Command is ShowManageStylesDialogCommand)
        {
            Dispatcher.BeginInvoke(() => _stylesDialog.BringToFront());
        }
        else if (e.Command is ShowFindReplaceDialogCommand)
        {
            Dispatcher.BeginInvoke(() => _findReplaceDialog.BringToFront());               
        }
        else if (e.Command is ShowInsertSymbolWindowCommand)
        {
            Dispatcher.BeginInvoke(() => _insertSymbolDialog.BringToFront());
        }
        else if (e.Command is ShowParagraphPropertiesDialogCommand)
        {
            Dispatcher.BeginInvoke(() => _paragraphPropertiesDialog.BringToFront());
        }
    }
}

 

 

 

0
Lucien
Top achievements
Rank 1
answered on 05 Jun 2013, 04:33 AM
I found a partial solution that I will share here.

The trick is to first get a reference to the Window that should be the OutOfBrowserOwner of the dialog windows. Since this has to be a 'normal' System.Windows.Window object you can't directly use a Rad control or other custom control or view.
You can get this reference by using:

var thisWindow = Window.GetWindow(this);

in an appropriate event of your screen or control. I found that it returns null in the constructor, so you'll have to do it in a later event.

Once you have that reference, you can then pass this to the OutOfBrowserOwner property of the dialog, like so:

var thisWindow = Window.GetWindow(this);
var paragraphPropertiesDialog = TemplateRadRichTextBox.ParagraphPropertiesDialog as RadParagraphPropertiesDialog;
paragraphPropertiesDialog.OutOfBrowserOwner = thisWindow;

Make sure you do this during or before the Command Executing event is triggered, so before the dialog opens.

The only issue I found so far is the ‘end of search’ message. This pops up when the user does a Find (or Find and Replace) after opening that dialog with Ctrl+F or Ctr+H or through some button. If you then click Find Next until you run out of matches a message pops up that tells you it could not find any more matches (of words to that extent) – this message still pops up in the main window (behind the current window)!

Lucien.
0
Vasil
Telerik team
answered on 07 Jun 2013, 01:58 PM
Hello Lucien,

If you would like to customize the behavior of the dialog, you can implement your own FindReplaceDialog. This is done fairly simple, as RadRichTextBox uses MEF to load all UI components. All you need to do is implement the IFindReplaceDialog and mark it with a [CustomFindReplaceDialog] attribute. You can find a project which shows how the default FindReplaceDialog can be used as custom in this SDK example.

You can download it and change the logic of the appearance of the RadAlerts. I hope this helps!

Regards,
Vasil
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Amruta
Top achievements
Rank 1
answered on 27 Mar 2015, 06:47 AM
Hi

When I insert table into RichTextBox editor ribbon(RadRichTextBoxRibbonUI) appearing in  front does not go away. That makes table 
hide behind ribbon till the time I click on textbox.
Can I make ribbon go away as soon as user inserts table.
This is urgent plsss help?
0
Amruta
Top achievements
Rank 1
answered on 27 Mar 2015, 06:49 AM
Hi

When I insert table in RadRichTextBox ribbon (RadRichTextBoxRibbonUI) does not go away.
That makes table hide behind ribbon till I click elsewhere.
Pls help this is urgent ???
Tags
RichTextBox
Asked by
John
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Lucien
Top achievements
Rank 1
Amruta
Top achievements
Rank 1
Share this question
or