ManageStylesDialog Opens Behind RadRichTextBox in Child Window

7 posts, 0 answers
  1. John
    John avatar
    8 posts
    Member since:
    Jul 2012

    Posted 11 Mar 2013 Link to this post

    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?
  2. Vasil
    Admin
    Vasil avatar
    124 posts

    Posted 14 Mar 2013 Link to this post

    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.

  3. DevCraft banner
  4. Lucien
    Lucien avatar
    3 posts
    Member since:
    May 2013

    Posted 03 Jun 2013 Link to this post

    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());
            }
        }
    }

     

     

     

  5. Lucien
    Lucien avatar
    3 posts
    Member since:
    May 2013

    Posted 04 Jun 2013 Link to this post

    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.
  6. Vasil
    Admin
    Vasil avatar
    124 posts

    Posted 07 Jun 2013 Link to this post

    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.

  7. Amruta
    Amruta avatar
    11 posts
    Member since:
    Mar 2015

    Posted 27 Mar 2015 in reply to Vasil Link to this post

    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?
  8. Amruta
    Amruta avatar
    11 posts
    Member since:
    Mar 2015

    Posted 27 Mar 2015 in reply to Vasil Link to this post

    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 ???
Back to Top
DevCraft banner