Xamarin Forms navigation issue
I am working on a Xamarin Forms Application and I am having a problem.
It looks like the navigation system is slightly off. I am using the root NavigationPage to host my pages and it works great all the time except ...
I have a subpage with a list of items. When listening, each element should display information about itself, on a separate page (whether it's modal or not).
However, it only works the first time. The second time I try to check the entry, it seems to load it twice (the font is thicker and a little ghostly) and when I click back one layer is left behind and the other moves with close animation (which is why I think it is was downloaded twice).
The code is as follows:
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>
The NoteDetails class only sets the BindingContext for the Note object passed. The Note class has four properties: String Title, String Date (its code field is a DateTime object, conversion is to a getter-setter), String Author, and String Content. All details are displayed correctly.
The only problem is retesting - it just refuses to work properly. What could be the problem?
source to share