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

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

19 Answers 548 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Brandmuscle
Top achievements
Rank 1
Brandmuscle asked on 20 Jan 2012, 05:12 PM
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

19 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 20 Jan 2012, 08:11 PM
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 >>

0
Tony Kennard
Top achievements
Rank 1
answered on 27 Jan 2012, 02:02 PM
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)
0
Iva Toteva
Telerik team
answered on 27 Jan 2012, 04:05 PM
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 >>

0
Tony Kennard
Top achievements
Rank 1
answered on 27 Jan 2012, 04:41 PM
Hi,

I'm also trying to do this in Silverlight.

Thanks
Tony
0
Iva Toteva
Telerik team
answered on 30 Jan 2012, 12:49 PM
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 >>

0
Brandmuscle
Top achievements
Rank 1
answered on 01 Feb 2012, 11:44 PM
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.
0
Brandmuscle
Top achievements
Rank 1
answered on 02 Feb 2012, 04:47 PM
Disregard this post.  I have rebooted and all seems to be working as expected now, I was having some weird VS 2010 issues.  Thanks.
0
InNeedForKnowledge
Top achievements
Rank 2
answered on 05 Jun 2012, 09:10 PM
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
0
Iva Toteva
Telerik team
answered on 06 Jun 2012, 01:20 PM
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 >>

0
InNeedForKnowledge
Top achievements
Rank 2
answered on 06 Jun 2012, 02:03 PM
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
0
InNeedForKnowledge
Top achievements
Rank 2
answered on 07 Jun 2012, 03:51 PM
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.
0
Boby
Telerik team
answered on 11 Jun 2012, 12:03 PM
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 >>

0
InNeedForKnowledge
Top achievements
Rank 2
answered on 18 Jun 2012, 08:27 PM
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
0
Iva Toteva
Telerik team
answered on 19 Jun 2012, 12:49 PM
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 >>

0
InNeedForKnowledge
Top achievements
Rank 2
answered on 19 Jun 2012, 11:30 PM
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?
0
Iva Toteva
Telerik team
answered on 20 Jun 2012, 08:52 AM
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 >>

0
InNeedForKnowledge
Top achievements
Rank 2
answered on 25 Jun 2012, 06:40 PM

 

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.
0
Iva Toteva
Telerik team
answered on 27 Jun 2012, 01:00 PM
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 >>

0
Sopan
Top achievements
Rank 1
answered on 25 Sep 2013, 07:27 AM
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


Tags
RichTextBox
Asked by
Brandmuscle
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Tony Kennard
Top achievements
Rank 1
Brandmuscle
Top achievements
Rank 1
InNeedForKnowledge
Top achievements
Rank 2
Boby
Telerik team
Sopan
Top achievements
Rank 1
Share this question
or