Back to Devexpress

HyperlinkEdit Class

wpf-devexpress-dot-xpf-dot-editors-4ceec6a9.md

latest4.3 KB
Original Source

HyperlinkEdit Class

A hyperlink editor.

Namespace : DevExpress.Xpf.Editors

Assembly : DevExpress.Xpf.Core.v25.2.dll

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
[DXLicenseWpfEditors]
public class HyperlinkEdit :
    BaseEdit,
    ICommandSource,
    ITextExportSettings,
    IExportSettings,
    ISupportTextHighlighting
vb
<DXLicenseWpfEditors>
Public Class HyperlinkEdit
    Inherits BaseEdit
    Implements ICommandSource,
               ITextExportSettings,
               IExportSettings,
               ISupportTextHighlighting

Remarks

The HyperlinkEdit control presents its content as a hyperlink. The text displayed within the control is underlined. When you activate the hyperlink functionality, the control executes the command specified by the HyperlinkEdit.NavigationUrl property.

You can use the following approaches to invoke the hyperlink functionality:

  • click the hyperlink
  • focus the hyperlink and press Space or Enter
  • invoke the DoNavigate() method.

The command in the HyperlinkEdit.NavigationUrl property can represent any valid command recognized by the system. For instance, the HyperlinkEdit.NavigationUrl can specify:

  • a URL to open in the default browser (www.devexpress.com)
  • a mailto: command that activates the default mail client (mailto:[email protected])
  • a path to a file or directory to open (c:\Program Files, \\Server\Public\setup.exe)

The HyperlinkEdit control has a HyperlinkEdit.RequestNavigation event to control hyperlink execution. Using this event, you can perform an action not recognized by the system, modify the command to execute, etc. For instance, if the HyperlinkEdit control has an e-mail without the mailto: prefix, the default hyperlink processing does nothing. However, you can handle the HyperlinkEdit.RequestNavigation event to make up a valid command by adding a mailto: prefix.

The code sample below demonstrates how to add the mailto: prefix for the HyperlinkEdit control’s displayed text (to enable opening a mail client).

xaml
<dxe:HyperlinkEdit 
                  x:Name="editor" 
                  AllowAutoNavigate="True" 
                  NavigationUrl="[email protected]" 
                  RequestNavigation="HyperlinkEdit_OnRequestNavigation"/>
csharp
void HyperlinkEdit_OnRequestNavigation(object sender, HyperlinkEditRequestNavigationEventArgs e) {
    string emailUri = "mailto:" + e.NavigationUrl;
    e.NavigationUrl = emailUri;
    e.Handled = true;
}
vb
Private Sub HyperlinkEdit_OnRequestNavigation(ByVal sender As Object, ByVal e As HyperlinkEditRequestNavigationEventArgs)
    Dim emailUri As String = "mailto:" & e.NavigationUrl
    e.NavigationUrl = emailUri
    e.Handled = True
End Sub

Inheritance

Object DispatcherObject DependencyObject Visual UIElement FrameworkElement Control BaseEdit HyperlinkEdit

See Also

HyperlinkEdit Members

DevExpress.Xpf.Editors Namespace