I making on chat app with VB.net+WPF and I need hyperlinks in that. For chat log I using RichTextBox and I adding new paragraph every time when new message come. So problem is, when I add hyperlink in RichTextBox it's not work because need CLICK event.
So, when I manually insert in my RichTextBox this:
And use this event:Code:<Hyperlink NavigateUri="http://www.google.com">Google</Hyperlink>
IT WORK !Code:Public Sub New() InitializeComponent() [AddHandler](Hyperlink.RequestNavigateEvent, New RoutedEventHandler(AddressOf OnNavigationRequest)) End Sub Public Sub OnNavigationRequest(ByVal sender As Object, ByVal e As RoutedEventArgs) Dim source = TryCast(e.OriginalSource, Hyperlink) If source IsNot Nothing Then Process.Start(source.NavigateUri.ToString()) End If End Sub
But I need it programmatically
When I do it link this:
When I click on HYPERLINK nothing happen...Code:Dim PARAGRAF As Paragraph = New Paragraph PARAGRAF.LineHeight = 1 Dim r As New Run("stefanACM: ") r.FontFamily = New System.Windows.Media.FontFamily("/MY APP;component/Fonts/#Arial") r.FontSize = 14 r.FontStyle = System.Windows.FontStyles.Normal r.FontWeight = System.Windows.FontWeights.Bold r.Foreground = bojaNick Dim r1 As New Run("test") r1.FontFamily = New System.Windows.Media.FontFamily("/MY APP;component/Fonts/#Arial") r1.FontSize = 14 r1.FontStyle = System.Windows.FontStyles.Normal r1.FontWeight = System.Windows.FontWeights.Bold r1.Foreground = bojaText Dim r2 As New Run("HYPERLINK ") Dim h As New Hyperlink(r2) h.NavigateUri = New Uri("http://www.google.com") PARAGRAF.Inlines.Add(r) PARAGRAF.Inlines.Add(r1) PARAGRAF.Inlines.Add(h) txtLog.Document.Blocks.Add(PARAGRAF)
Can anybody help me with this. I think something stupid is problem but I am tired and can't find that :|
Thanks in advice




Reply With Quote