TargetInvocationException while adding TabControl to Grid

1 posts, 0 answers
  1. JC
    JC avatar
    1 posts
    Member since:
    Sep 2012

    Posted 10 Sep 2012 Link to this post

    Hi,

    I have this TabControl defined in mainPage.cs. When I navigate to Page A, a new tab will be added to the TabControl. The purpose of me declaring TabControl in mainPage.cs is to keep the TabControl object alive so that it won't be destructed when I navigate to other page. I can add new tab as I want, but after I navigate to Page B, and go back to Page A, there is "TargetInvocationException" error when I perform the following act:

    // Add rootPage.tabControl to gridReport

    Grid.SetColumn(rootPage.tabControl, 0);

    Grid.SetRow(rootPage.tabControl, 0); // Tab display at Grid.Row = 0

    gridReport.Children.Add(rootPage.tabControl); // Add tabControl to gridReport

    Note: tabControl is defined in MainPage.cs.

    My expectation will be after I navigate to page B, then back to Page A, when I add rootPage.tabControl, the gridReport will display the tabControl, what do I miss out??
    Thanks alot!!

Back to Top