两天前,我用RestApi客户端写了有关Xamarin.Forms中listView的问题。这是链接Xamarin listView second click don't show item。
我放了很多代码,因为我找不到错误。我可能注意到了这个问题?
我有代码的ModelView(ZasobyListContentPageViewModel.cs)
...
public DelegateCommand<UnivElement> ItemTappedCommand => _selItemCommand ?? (_selItemCommand = new DelegateCommand<UnivElement>(ShowMyDateDetails));
private async void ShowMyDateDetails(UnivElement paramData)
{
var parameters = new NavigationParameters
{
{"myItem", paramData },
{"title", paramData.C1 }
};
await _navigationService.NavigateAsync("ZasobDetailsContentPage", parameters);
}
...
在ZasobDetailContentPageViewModel.cs中,我有:
...
public void OnNavigatedTo(NavigationParameters parameters)
{
if (parameters.ContainsKey("myItem"))
{
UnivElemDetails = (UnivElement)parameters["myItem"];
}
if (parameters.ContainsKey("title"))
{
Title = (string)parameters["title"];
}
}
...
我调试了应用程序,并注意到了该代码
await _navigationService.NavigateAsync("ZasobDetailsContentPage", parameters);
public void OnNavigatedTo(NavigationParameters parameters)
{
if (parameters.ContainsKey("myItem"))
{
UnivElemDetails = (UnivElement)parameters["myItem"];
}
if (parameters.ContainsKey("title"))
{
Title = (string)parameters["title"];
}
}
ZasobDetailContentPageViewModel.cs中的仅在列表元素的第一次单击上运行,并且各种UnivElemDetails与我的xaml绑定。
这可能是个问题吗?我该怎么办?
感谢您的帮助!