How to open an external browser by hyperlink, in a browser it would be target='_top'.
What is the code in a WPF netcore 3.1 app?
Use CommandParameter
<TextBlock> <Hyperlink CommandParameter="{Binding ExternalURL}" Command="{Binding NavHomeViewCommand}" >Open in Browser ... </Hyperlink> </TextBlock>
Change DelegateCommand to use object parameter (using the prismlibrary mvvm pattern)
navHomeViewCommand = new DelegateCommand<object>(NavHomeView);
Command Properties:
public string ExternalURL{ get => "https://www.google.com/";} private readonly ICommand navHomeViewCommand; public ICommand NavHomeViewCommand { get { return navHomeViewCommand; } }
Open a browser
private void NavHomeView(object ID) { if(obj is string destinationurl) System.Diagnostics.Process.Start("https://google.com"); //??????? }
An exception is thrown 'unknown executable'.