Can I customize the default "Insert Hyperlink" dialog window?

20 posts, 0 answers
  1. Brandmuscle
    Brandmuscle avatar
    19 posts
    Member since:
    Nov 2008

    Posted 20 Jan 2012 Link to this post

    I am new to the RadRichTextBox and have a specific requirement in my application... I would like to customize the default dialog window that pops up when you click "Hyperlink" on the RadRichTextBox toolbar.  Specifically, I want to add ComboBox controls to the dialog so that the user can select the path, file name, etc. for  specific documents to link to - the user will not know the address of the document and will not be able to manually type it in to the Address textbox, which is the only way I see to link to a document by default.

    I see in the xaml markup of the RadRibbonButton:

    telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ShowInsertHyperlinkDialogCommand}"

    I'm assuming this ShowInsertHyperlinkDialogCommand is in the Telerik assembly.  Do you have suggestions for accomplishing the requirements mentioned above?  Thanks
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 20 Jan 2012 Link to this post

    Hello Dan,

    All UI that RadRichTextBox uses - dialogs, context menu, selection mini toolbar, etc., are loaded by MEF and can be substituted for others.
    What you need to do in order to accomplish this is to implement the IInsertHyperlinkDialog and add the [CustomInsertHyperlinkDialog] attribute to your implementation. Please find attached a project illustrating how this can be done. In the example, I have included the default InsertHyperlinkDialog and used it as a custom one.

    All the best,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Tony Kennard
    Tony Kennard avatar
    4 posts
    Member since:
    Nov 2009

    Posted 27 Jan 2012 Link to this post

    Do you have a VB.NET example?

    I have converted the C# example, but I'm getting:

    "CustomInsertHyperlinkDialog' must implement 'Sub ShowDialog(text As String, currentHyperlinkInfo As Model.HyperlinkInfo, bookmarkNames As System.Collections.Generic.IEnumerable(Of String), insertHyperlinkCallback As System.Action(Of String, Model.HyperlinkInfo), cancelCallback As System.Action)' for interface 'Telerik.Windows.Documents.UI.Extensibility.IInsertHyperlinkDialog'"

    Even though I have the following in the code:
    Public Sub ShowDialog(text As String, currentHyperlinkInfo As Model.HyperlinkInfo, bookmarkNames As System.Collections.Generic.IEnumerable(Of String), insertHyperlinkCallback As System.Action(Of String, Model.HyperlinkInfo), cancelCallback As System.Action)
  5. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 27 Jan 2012 Link to this post

    Hi Tony,

    The method must be declared as follows:
    Public Overloads Sub ShowDialog(text As String, currentHyperlinkInfo As HyperlinkInfo, bookmarkNames As IEnumerable(Of String), insertHyperlinkCallback As Action(Of String, HyperlinkInfo), cancelCallback As Action, owner As RadRichTextBox) Implements IInsertHyperlinkDialog.ShowDialog
        Me.ShowDialogInternal(text, currentHyperlinkInfo, bookmarkNames, insertHyperlinkCallback, cancelCallback, owner)
    End Sub

    Please find attached the demo converted to VB.

    Greetings,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Tony Kennard
    Tony Kennard avatar
    4 posts
    Member since:
    Nov 2009

    Posted 27 Jan 2012 Link to this post

    Hi,

    I'm also trying to do this in Silverlight.

    Thanks
    Tony
  7. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 30 Jan 2012 Link to this post

    Hello Tony,

    I assumed the sample you needed was for WPF, since this is the WPF forum.

    Please find attached the same demo for Silverlight.

    Greetings,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  8. Brandmuscle
    Brandmuscle avatar
    19 posts
    Member since:
    Nov 2008

    Posted 01 Feb 2012 Link to this post

    Thanks for your example project.  I am having an issue when adding a radcombobox SelectionChanged event to a custom combobox I have added to CustomInsertHyperlinkDialog.xaml.  For some reason, the entire app freezes up when I click the add hyperlink button if I have this event wired into the xaml, and I have to terminate the debugging.  When I remove the SelectionChanged event from the xaml, the dialog pops up fine and shows my combo boxes - but I have to be able to access events.  Here is my code:

    <telerik:RadComboBox ItemsSource="{Binding Source={StaticResource DataSource}, Path=Folders}" DisplayMemberPath="FolderName"
                Grid.Row="5" x:Name="FolderComboBox" HorizontalAlignment="Left" VerticalAlignment="Center" Width="180"
                Grid.Column="1" SelectedIndex="0" SelectionChanged="FolderComboBox_SelectionChanged">
            </telerik:RadComboBox>

    and in the code behind:

            private void FolderComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
            {
                string s = "";
            }

    Again, when the selectionchanged event is not included in the xaml, the dialog opens fine.  Please provide suggestions on why it is behaving this way, or let me know if you need to see the entire project.  I have simply added my controls to the sample project you sent and will be happy to upload the entire solution.  Thanks.
  9. Brandmuscle
    Brandmuscle avatar
    19 posts
    Member since:
    Nov 2008

    Posted 02 Feb 2012 Link to this post

    Disregard this post.  I have rebooted and all seems to be working as expected now, I was having some weird VS 2010 issues.  Thanks.
  10. InNeedForKnowledge
    InNeedForKnowledge avatar
    9 posts
    Member since:
    Jan 2012

    Posted 05 Jun 2012 Link to this post

    Hi,
     I've try the solution you attached to the post, and it let me customize the dialog just fine. But the link inserted into the textbox control by this line:
     insertHyperlinkCallback(hyperlinkText, hyperlinkInfo) It doesn't serve to my purposes
     Is there any way to implement this callback by myself?, because I need to create my own a href tag, adding some extra values
     
    thanks
  11. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 06 Jun 2012 Link to this post

    Hello Jose Loria,

    It is not possible to change the callback that the editor uses to insert hyperlinks in the editor.

    If you would like to achieve some other behavior, you can implement another command and wire your UI to work with it. When it comes to the changes you have mentioned, could you elaborate more on your scenario?

    Regards,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  12. InNeedForKnowledge
    InNeedForKnowledge avatar
    9 posts
    Member since:
    Jan 2012

    Posted 06 Jun 2012 Link to this post

    Hi, Iva
    First thank you for your quick response. Our scenario is like this: we use the Editor to create some email templates, in those templates we add specific elements to some specific tags, in the case of "a href" tag, this added elements let us, in a later process, to match data from the database and execute some task base on the click to those links. We call'em "trackable links" cause when the user click on them in the template, he get redirected to some URL which count the "hit" and redirects the user to the original link.

    But since there's no way to change/implement this callback, could we insert data to the editor directly from this dialog? I'm thinking maybe we can add a checkbox and modify the behavior on the Ok button depending on the checkbox been checked or not, if is checked then "inject" our customized link directly to the editor, if is not the execute the behavior as it is now? it's possible?

    thanks again for you helping hand
    best regards
  13. InNeedForKnowledge
    InNeedForKnowledge avatar
    9 posts
    Member since:
    Jan 2012

    Posted 07 Jun 2012 Link to this post

    Hi,
    We decided to resolve this issue with a workaround, creating our own custom value for the href element in the A tag since we have to reprocess it later, that won't be a big problem.

    But now we have another issue, we use the example project attached to an earlier reply, but that example uses the Q1 2012 Library, and we are using the Q3 2011 Library in our project because when we try the Q4 2011 we experience some troubles like missing datacontext on some callbacks.

    Now it seems, in Q3 2011 Library there's no RadRichTextBoxWindow class in the Telerik.Windows.Controls.RichTextBoxUI.Dialogs namespace or any other namespace
    and the CustomInsertHyperlink class can't inherit from it. Should we change this RadRichTextBoxWindow class for another in the Q3 2011 Library?

    Migrating to Q1 2011 is not an option for us, cause don't have the time to test the impact of that migration, but we're in need of resolving this CustomInsertHyperlink issue first.
  14. Boby
    Admin
    Boby avatar
    595 posts

    Posted 11 Jun 2012 Link to this post

    Hi InNeedForKnowledge,
    RadRichTextBoxWindow was introduced lately as a base class for all built-in RadRichTextBox dialogs, and for now its only function is to resolve some theme-related issues. In your case you can inherit directly from RadWindow and check if this satisfy your requirements.

    Kind regards,
    Boby
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  15. InNeedForKnowledge
    InNeedForKnowledge avatar
    9 posts
    Member since:
    Jan 2012

    Posted 18 Jun 2012 Link to this post

    I've try the solution attached in this thread, but for some reason, when I take the files to my solution my Editor Control won't show the CustomInsertHyperlinkDialog, If I copy my Editor Control to your solution it works perfectly. But as I told when I do the opposite in my project the original InsertHyperlinkDialog keeps showing up. What am I doing wrong? How should I attach the CustomInsertHyperlinkDialog to my control. I thought, it was as simple as put the files in my project in the same folder as my Editor Control.

    thanks
  16. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 19 Jun 2012 Link to this post

    Hi Jose,

    By default, RadRichTextBox loads the UI it uses - SelectionMiniToolBar, ContextMenu, all dialogs, etc., through MEF. That is why normally adding the respective attribute (e.g. [CustomInsertHyperlinkDialog]) is sufficient to get it working.

    However, there are some cases when MEF does not work. In that case, you can simply set the InsertHyperlinkDialog property of RadRichTextBox to a new instance of the custom dialog or follow the approach described in this article.

    Kind regards,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  17. InNeedForKnowledge
    InNeedForKnowledge avatar
    9 posts
    Member since:
    Jan 2012

    Posted 19 Jun 2012 Link to this post

    I've been trying the solution propused with no luck at all. 

    I try:

    this.radRichTextBox.InsertHyperlinkDialog = new CustomInsertHyperlinkDialog();


    and also try with

    RadCompositionInitializer.Catalog = new TypeCatalog( typeof(CustomInsertHyperlinkDialog));



    In my "test" solution but when I put the files in my project won't work, any Ideas?
  18. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 20 Jun 2012 Link to this post

    Hi Jose,

    We have not encountered such an issue and have no other guesses what could be wrong with your application.
    Since the demo attached in one of the previous posts works correctly on your end as well, please try comparing it to your project. You can also open a support ticket and attach your application, so that we can investigate further.

    Regards,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  19. InNeedForKnowledge
    InNeedForKnowledge avatar
    9 posts
    Member since:
    Jan 2012

    Posted 25 Jun 2012 Link to this post

     

    Finally I could isolate the problem I'm experiencing for some reason, I can't find, after assing the InsertHyperLinkDialog property the value for this property gets change back to the original value. I've decided to implement my own Command and force the display of my CustomInsertHyperlinkDialog.
  20. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 27 Jun 2012 Link to this post

    Hi Jose,

    We don't think that there is a bug in the way the default command handles custom InsertHyperlinkDialogs, especially since it works in the demo we have prepared.

    However, as we cannot reproduce the problem and do not know your project in detail, you probably have a better view on what could be wrong and better chances of solving the issue.

    All the best,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  21. Sopan
    Sopan avatar
    34 posts
    Member since:
    May 2012

    Posted 25 Sep 2013 Link to this post

    I have seen your demo,
     
    I want know how to add this local dialogue window CustomInsertHyperlinkDialog.xaml, as window or as UserControl or what

    and what is the procedure to add this as local window.

    Thanks 
    Sopan Vaidya


Back to Top
UI for WPF is Visual Studio 2017 Ready