I have looked at various solutions on how to have a simple URL on a textfield, a rich text field in a WPF implementation using C#.
Tried to implement solutions on Clicking HyperLinks in a RichTextBox without holding down CTRL - WPF and Add clickable hyperlinks to a RichTextBox without new paragraph. It just looks overly complicated for what i think should be a simple task.
<RichTextBox IsReadOnly="True" IsDocumentEnabled="True"> <FlowDocument> <Paragraph FontSize="12"> See www.google.com</Paragraph> </FlowDocument> </RichTextBox> I also tried the implementation on the link Example using Hyperlink in WPF
Here, the error I get is this. MainWindow does not contain a definition of Hyperlink_RequestNAvigate and no accessible extension method hyperlink_RequestNavigate accepting a first argument of type MainWindow could be found, are you missing a using directive of an assembly reference.
<TextBlock> <Hyperlink NavigateUri="http://www.google.com" RequestNavigate="Hyperlink_RequestNavigate"> Click here </Hyperlink> </TextBlock> code behind
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) { // for .NET Core you need to add UseShellExecute = true // see https://learn.microsoft.com/dotnet/api/system.diagnostics.processstartinfo.useshellexecute#property-value Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; } I am looking to have a text saying for more information click here and if the user clicks on click here, they navigate to a predefined url.
Hyperlink_RequestNavigateinto fileMainWindow.xaml.csbut rather in some other cs file...