I am working on a visual basic WPF project and I need to be able to add hyperlinks dynamically to the WPF form. I am trying to add a Hyperlink object to a text block object on the form.
My WPF XAML is
<Grid>
<TextBlock Name="URLTextBlock">
</TextBlock>
</Grid>
My VB code is
Public Overloads Overrides Sub TransferDataIn()
URLTextBlock.Inlines.Clear()
Dim h As New Hyperlink
h.NavigateUri = New Uri("http://www.bing.com")
h.RequestNavigate += Hyperlink_RequestNavigate()
h.TargetName = "Bing"
h.Inlines.Add("Bing")
URLTextBlock.Inlines.Add(h)
End Sub
Private Sub Hyperlink_RequestNavigate(sender As Object, e As RequestNavigateEventArgs)
Process.Start(New ProcessStartInfo(e.Uri.AbsoluteUri))
End Sub
The problem I am having is adding the RequestNavigate value. The line "h.RequestNavigate += Hyperlink_RequestNavigate()" does not work. I know this is how it is done in C#. In Visual Basic I get the error "Public Event RequestNavigate As RequestNavigateEventHandler is an event, and cannot be called directly. User a "RaiseEvent' statement to raise an event."
How do I do this in Visual Basic?