XamarinForms: how use a Custom Navigation Page










1















I order to have a cutom navigation on a specific view on my app,
I create a Custom Navigation ios:



public class CustomNavigationPageRenderer : NavigationRenderer

public override void ViewDidLoad()

base.ViewDidLoad();

UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
UINavigationBar.Appearance.ShadowImage = new UIImage();
UINavigationBar.Appearance.BackgroundColor = UIColor.Clear;
UINavigationBar.Appearance.TintColor = UIColor.White;
UINavigationBar.Appearance.BarTintColor = UIColor.Clear;
UINavigationBar.Appearance.Translucent = true;




and a common interface class:



public partial class CustomPage : NavigationPage

public CustomPage(): base()

InitializeComponent();


public CustomPage(Page root) : base(root)

InitializeComponent();


public bool IgnoreLayoutChange get; set; = false;

protected override void OnSizeAllocated(double width, double height)

if (!IgnoreLayoutChange)
base.OnSizeAllocated(width, height);




Now, In my specific view, how have I use it?
I need to set on false the original navigation? (NavigationPage.SetHasNavigationBar(this, false);​)



public MySpecificViewNeedCustoNAv()
{

CustomPage myNavigationPage = new CustomPage();
...









share|improve this question




























    1















    I order to have a cutom navigation on a specific view on my app,
    I create a Custom Navigation ios:



    public class CustomNavigationPageRenderer : NavigationRenderer

    public override void ViewDidLoad()

    base.ViewDidLoad();

    UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
    UINavigationBar.Appearance.ShadowImage = new UIImage();
    UINavigationBar.Appearance.BackgroundColor = UIColor.Clear;
    UINavigationBar.Appearance.TintColor = UIColor.White;
    UINavigationBar.Appearance.BarTintColor = UIColor.Clear;
    UINavigationBar.Appearance.Translucent = true;




    and a common interface class:



    public partial class CustomPage : NavigationPage

    public CustomPage(): base()

    InitializeComponent();


    public CustomPage(Page root) : base(root)

    InitializeComponent();


    public bool IgnoreLayoutChange get; set; = false;

    protected override void OnSizeAllocated(double width, double height)

    if (!IgnoreLayoutChange)
    base.OnSizeAllocated(width, height);




    Now, In my specific view, how have I use it?
    I need to set on false the original navigation? (NavigationPage.SetHasNavigationBar(this, false);​)



    public MySpecificViewNeedCustoNAv()
    {

    CustomPage myNavigationPage = new CustomPage();
    ...









    share|improve this question


























      1












      1








      1








      I order to have a cutom navigation on a specific view on my app,
      I create a Custom Navigation ios:



      public class CustomNavigationPageRenderer : NavigationRenderer

      public override void ViewDidLoad()

      base.ViewDidLoad();

      UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
      UINavigationBar.Appearance.ShadowImage = new UIImage();
      UINavigationBar.Appearance.BackgroundColor = UIColor.Clear;
      UINavigationBar.Appearance.TintColor = UIColor.White;
      UINavigationBar.Appearance.BarTintColor = UIColor.Clear;
      UINavigationBar.Appearance.Translucent = true;




      and a common interface class:



      public partial class CustomPage : NavigationPage

      public CustomPage(): base()

      InitializeComponent();


      public CustomPage(Page root) : base(root)

      InitializeComponent();


      public bool IgnoreLayoutChange get; set; = false;

      protected override void OnSizeAllocated(double width, double height)

      if (!IgnoreLayoutChange)
      base.OnSizeAllocated(width, height);




      Now, In my specific view, how have I use it?
      I need to set on false the original navigation? (NavigationPage.SetHasNavigationBar(this, false);​)



      public MySpecificViewNeedCustoNAv()
      {

      CustomPage myNavigationPage = new CustomPage();
      ...









      share|improve this question
















      I order to have a cutom navigation on a specific view on my app,
      I create a Custom Navigation ios:



      public class CustomNavigationPageRenderer : NavigationRenderer

      public override void ViewDidLoad()

      base.ViewDidLoad();

      UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
      UINavigationBar.Appearance.ShadowImage = new UIImage();
      UINavigationBar.Appearance.BackgroundColor = UIColor.Clear;
      UINavigationBar.Appearance.TintColor = UIColor.White;
      UINavigationBar.Appearance.BarTintColor = UIColor.Clear;
      UINavigationBar.Appearance.Translucent = true;




      and a common interface class:



      public partial class CustomPage : NavigationPage

      public CustomPage(): base()

      InitializeComponent();


      public CustomPage(Page root) : base(root)

      InitializeComponent();


      public bool IgnoreLayoutChange get; set; = false;

      protected override void OnSizeAllocated(double width, double height)

      if (!IgnoreLayoutChange)
      base.OnSizeAllocated(width, height);




      Now, In my specific view, how have I use it?
      I need to set on false the original navigation? (NavigationPage.SetHasNavigationBar(this, false);​)



      public MySpecificViewNeedCustoNAv()
      {

      CustomPage myNavigationPage = new CustomPage();
      ...






      xamarin navigation customization






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 8:13







      doxsi

















      asked Nov 16 '18 at 7:55









      doxsidoxsi

      6201235




      6201235






















          1 Answer
          1






          active

          oldest

          votes


















          0















          need to set on false the original navigation?




          No , you can refer the following code.



          For example




          Creating the Root Page in App.cs




          public App ()

          MainPage = new CustomPage (new xxxpage());




          Pushing Pages to the Navigation Stack in your page




          async void ButtonClicked (object sender, EventArgs e)

          await Navigation.PushAsync (new xxxpage());






          share|improve this answer

























          • Tx. Children not exists in the current context

            – doxsi
            Nov 20 '18 at 9:05












          • It is a tabbedpage not a content page

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:08











          • mine is not a tabbed page

            – doxsi
            Nov 20 '18 at 9:11











          • look at my update answer

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:16











          • Tell me whether the answer works

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:40











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333598%2fxamarinforms-how-use-a-custom-navigation-page%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0















          need to set on false the original navigation?




          No , you can refer the following code.



          For example




          Creating the Root Page in App.cs




          public App ()

          MainPage = new CustomPage (new xxxpage());




          Pushing Pages to the Navigation Stack in your page




          async void ButtonClicked (object sender, EventArgs e)

          await Navigation.PushAsync (new xxxpage());






          share|improve this answer

























          • Tx. Children not exists in the current context

            – doxsi
            Nov 20 '18 at 9:05












          • It is a tabbedpage not a content page

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:08











          • mine is not a tabbed page

            – doxsi
            Nov 20 '18 at 9:11











          • look at my update answer

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:16











          • Tell me whether the answer works

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:40















          0















          need to set on false the original navigation?




          No , you can refer the following code.



          For example




          Creating the Root Page in App.cs




          public App ()

          MainPage = new CustomPage (new xxxpage());




          Pushing Pages to the Navigation Stack in your page




          async void ButtonClicked (object sender, EventArgs e)

          await Navigation.PushAsync (new xxxpage());






          share|improve this answer

























          • Tx. Children not exists in the current context

            – doxsi
            Nov 20 '18 at 9:05












          • It is a tabbedpage not a content page

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:08











          • mine is not a tabbed page

            – doxsi
            Nov 20 '18 at 9:11











          • look at my update answer

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:16











          • Tell me whether the answer works

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:40













          0












          0








          0








          need to set on false the original navigation?




          No , you can refer the following code.



          For example




          Creating the Root Page in App.cs




          public App ()

          MainPage = new CustomPage (new xxxpage());




          Pushing Pages to the Navigation Stack in your page




          async void ButtonClicked (object sender, EventArgs e)

          await Navigation.PushAsync (new xxxpage());






          share|improve this answer
















          need to set on false the original navigation?




          No , you can refer the following code.



          For example




          Creating the Root Page in App.cs




          public App ()

          MainPage = new CustomPage (new xxxpage());




          Pushing Pages to the Navigation Stack in your page




          async void ButtonClicked (object sender, EventArgs e)

          await Navigation.PushAsync (new xxxpage());







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 20 '18 at 9:28

























          answered Nov 19 '18 at 2:20









          Lucas Zhang - MSFTLucas Zhang - MSFT

          2,7512210




          2,7512210












          • Tx. Children not exists in the current context

            – doxsi
            Nov 20 '18 at 9:05












          • It is a tabbedpage not a content page

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:08











          • mine is not a tabbed page

            – doxsi
            Nov 20 '18 at 9:11











          • look at my update answer

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:16











          • Tell me whether the answer works

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:40

















          • Tx. Children not exists in the current context

            – doxsi
            Nov 20 '18 at 9:05












          • It is a tabbedpage not a content page

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:08











          • mine is not a tabbed page

            – doxsi
            Nov 20 '18 at 9:11











          • look at my update answer

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:16











          • Tell me whether the answer works

            – Lucas Zhang - MSFT
            Nov 20 '18 at 9:40
















          Tx. Children not exists in the current context

          – doxsi
          Nov 20 '18 at 9:05






          Tx. Children not exists in the current context

          – doxsi
          Nov 20 '18 at 9:05














          It is a tabbedpage not a content page

          – Lucas Zhang - MSFT
          Nov 20 '18 at 9:08





          It is a tabbedpage not a content page

          – Lucas Zhang - MSFT
          Nov 20 '18 at 9:08













          mine is not a tabbed page

          – doxsi
          Nov 20 '18 at 9:11





          mine is not a tabbed page

          – doxsi
          Nov 20 '18 at 9:11













          look at my update answer

          – Lucas Zhang - MSFT
          Nov 20 '18 at 9:16





          look at my update answer

          – Lucas Zhang - MSFT
          Nov 20 '18 at 9:16













          Tell me whether the answer works

          – Lucas Zhang - MSFT
          Nov 20 '18 at 9:40





          Tell me whether the answer works

          – Lucas Zhang - MSFT
          Nov 20 '18 at 9:40



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333598%2fxamarinforms-how-use-a-custom-navigation-page%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          政党

          天津地下鉄3号線