更新时间:2022-11-11 20:42:01
您使用的是错误的,使用HtmlWebViewSource
时,您需要指定实际的HTML而不是要转到的URL.如果要导航到URL,请在Source
属性中指定它.
You're using it wrong, when using the HtmlWebViewSource
you need to specify actual HTML instead of the URL where you want to go to. If you want to navigate to a URL, specify it in the Source
property.
如果要绑定它,则必须实现类似这样的东西.
If you want to bind it, you have to implement something like this.
在您的视图模型中创建一个字符串属性:
In your view model create a string property:
public string UrlToGoTo { get; set; }
然后像平常一样设置它,确保以某种方式实现了INotifyPropertyChanged
.
Then set it like you normally would, make sure to have INotifyPropertyChanged
is implemented somehow.
然后,像这样连接您的WebView
:
Then, wire up your WebView
like this:
<WebView Source="{Binding UrlToGoTo}"
HeightRequest= "300"
WidthRequest="250"
Navigated="Handle_Navigated"
VerticalOptions="FillAndExpand"
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1" />