This is a migrated thread and some comments may be shown as answers.

TargetInvocationException while adding TabControl to Grid

0 Answers 20 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
JC
Top achievements
Rank 1
JC asked on 11 Sep 2012, 01:05 AM

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!!

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
JC
Top achievements
Rank 1
Share this question
or