티스토리 뷰

728x90
반응형

 Xamarin.Forms Tabbed Page Move CurrentPage

==>  this.Parent.Parent.Parent.Parent as TabbedPage

 

Console.WriteLine("Parent1!" + this.Parent.ToString());
Console.WriteLine("Parent2!" + this.Parent.Parent.ToString());
Console.WriteLine("Parent3!" + this.Parent.Parent.Parent.ToString());
Console.WriteLine("Parent4!" + this.Parent.Parent.Parent.Parent.ToString());

<print result>

2021-07-26 16:29:11.833738+0900 Ecs.iOS[34906:1120249] Parent1!Xamarin.Forms.Grid
2021-07-26 16:29:11.834086+0900 Ecs.iOS[34906:1120249] Parent2!Xamarin.Forms.StackLayout
2021-07-26 16:29:11.834314+0900 Ecs.iOS[34906:1120249] Parent3!Ecs.ViewPages.TabPage1
2021-07-26 16:29:11.834536+0900 Ecs.iOS[34906:1120249] Parent4!Ecs.Views.MainPage

 

 

async void TapGestureRecognizer_Tapped(System.Object sender, System.EventArgs e)
        {
            try
            {
                var tabbedPage = this.Parent.Parent.Parent.Parent as TabbedPage;
                tabbedPage.CurrentPage = tabbedPage.Children[3];  // 4번째  tabpage 이동
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.Message);
            }
        }

반응형
댓글