【发布时间】:2020-05-27 14:46:12
【问题描述】:
如何通过超链接打开外部浏览器,在浏览器中应该是target='_top'。
WPF netcore 3.1 应用程序中的代码是什么?
-
使用命令参数
<TextBlock> <Hyperlink CommandParameter="{Binding ExternalURL}" Command="{Binding NavHomeViewCommand}" >Open in Browser ... </Hyperlink> </TextBlock> -
更改 DelegateCommand 以使用对象参数(使用 prismlibrary mvvm 模式)
navHomeViewCommand = new DelegateCommand<object>(NavHomeView); -
命令属性:
public string ExternalURL{ get => "https://www.google.com/";} private readonly ICommand navHomeViewCommand; public ICommand NavHomeViewCommand { get { return navHomeViewCommand; } } -
打开浏览器
private void NavHomeView(object ID) { if(obj is string destinationurl) System.Diagnostics.Process.Start("https://google.com"); //??????? }
抛出“未知可执行文件”异常。
【问题讨论】:
-
看看能不能解决你的问题
-
.netcore3.1 不是你日常使用的 WPF
-
“重复”问题中的答案均无效。经过多次试验和错误,得到的“hack”是: System.Diagnostics.Process.Start("cmd", "/C start" + " " + destinationurl);
-
我重新打开这个问题,你可以自己回答
-
您可能还想标记这个。 .netcore 3.1
标签: c# wpf browser .net-core-3.1