我正在使用Xamarin Forms应用程序,但遇到了一个问题。
导航系统似乎有点偏离。我正在使用根NavigationPage来托管我的页面,并且除了...之外,它一直都能正常工作。
我有一个带有项目列表的子页面。轻按时,每个项目都应在单独的页面上显示有关其自身的信息(无论是否为模态)。
但是,它只能在第一次使用。第二次尝试检查条目时,它似乎加载了两次(字体较粗且有点重影),当我按回时,一层保留在后面,而另一层随着关闭的动画移动(这就是为什么我认为是加载两次)。
代码如下:
public partial class NotesPage : ContentPage {
protected override void OnAppearing()
{
base.OnAppearing();
NotesList.ItemsSource = VM.Notes; // VM is my ViewModel, NotesList is a ListView defined in XAML
NotesList.ItemSelected += async (sender, e) =>
{
if (e.SelectedItem == null) return;
await Navigation.PushAsync(new NoteDetails((Note)e.Item));
((ListView)sender).SelectedItem = null;
};
}
}
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Views.Notes.NoteDetails">
<StackLayout>
<Label Text="{Binding Title}" />
<Label Text="{Binding Date}" />
<Label Text="{Binding Author}" />
<Label Text="{Binding Content}" />
</StackLayout>
</ContentPage>
NoteDetails的类仅将BindingContext设置为传递的Note对象。Note类具有四个属性:字符串标题,字符串日期(其代码返回字段是DateTime对象,转换发生在getter-setter中),字符串作者和字符串内容。所有详细信息均正确显示。
唯一的问题是第二次检查-它只是拒绝正常工作。可能是什么问题?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句