0
在我的android項目中,webview url是動態的。我在視圖方面使用mvvmcros綁定,但它不是動態的。如果視圖模型上的網址內容正在改變其未被更新的視圖。誰能幫我嗎?Xamarin Android:基於Viewmodel的動態更新UI
查看
public string WebContentUrll { get; set; }
protected override void OnCreate(Android.OS.Bundle bundle)
{
var bindingSet = this.CreateBindingSet<view, ViewModel>();
bindingSet.Bind(this).For(v => v.WebContentUrll).To(vm => vm.WebContentUrl).TwoWay();
}
視圖模型
private string webContentUrl;
public string WebContentUrl
{
get
{
return webContentUrl;
}
set
{
webContentUrl = value;
RaisePropertyChanged(() => webContentUrl);
}
}
public void Init()
{
webContentUrl = "https://.."'
}
網頁內容的URL在頁面加載後,但在Android的看法是不能夠獲得視圖模型的變化值新的更新網址。
任何人都可以請指教。謝謝。
更新
Web視圖打開按鈕上點擊該URL是頁面加載後更新,點擊之前該按鈕
我不確定你想要在這裏做什麼。你在視圖中使用WebView控件嗎? ViewModel是否負責更改URL?你現在擁有它的方式,它只是改變視圖的屬性...它不會加載新的頁面。 – Kiliman