Arti February 2016

Back Button on first page when NavigationPage used

I have a custom listview on my Xamarin.Forms apps which has switch control for multi selection. Now I have this issue where in I get backbutton on the first page of my app. The back Button on the first page is not required as it redirects to a black page. I know it has to do something with Navigation.PushAsync. But I could not figure it out where the change is required. If anyone can direct me in correct way wil be helpful.

Here is SelectMultipleBasePage.cs page:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
//using System.Reflection.Emit;
using System.Text;
using Xamarin.Forms;

namespace _____
{
    public class SelectMultipleBasePage<T> : ContentPage
    {
        public class WrappedSelection<T> : INotifyPropertyChanged
        {
            public T Item { get; set; }
            bool isSelected = false;
            public bool IsSelected
            {
                get
                {
                    return isSelected;
                }
                set
                {
                    if (isSelected != value)
                    {
                        isSelected = value;
                        PropertyChanged(this, new PropertyChangedEventArgs("IsSelected"));
                        //                      PropertyChanged (this, new PropertyChangedEventArgs (nameof (IsSelected))); // C# 6
                    }
                }
            }
            public event PropertyChangedEventHandler PropertyChanged = delegate { };
        }
        public class WrappedItemSelectionTemplate : ViewCell
        {
            public WrappedItemSelectionTemplate()
                : base()
            {

                Grid objGrid = new Grid();
                objGrid.BackgroundColor = Color.Gray;
                objGrid.RowDefinitions.Add(new RowDefinition
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });

         

Answers


Marc Harry February 2016

Instead of doing await Navigation.PushAsync(multiPage); change this to:

Content = multiPage;

This should set the page content for the ListPage you have passed to the NavigationPage to be the SelectMultipleBasePage<T> you setup in code. And this should be the first page in the Navigation and there shouldn't be a back button present.

EDIT: Sorry try changing it to: Content = multiPage.Content;

Post Status

Asked in February 2016
Viewed 1,704 times
Voted 12
Answered 1 times

Search




Leave an answer