I have a Silverlight app that displays a number of "pages". Each page is a different XAML file with different code behind. The pages are numbered sequentially as follows: page_1, page_2, page_3, ..., Page_n. The pages are not static and will be dynamically generated.
Since I don't know the total number of pages, I have to load each page at runtime using the Dynamic keyword. My code is as follows as is working perfectly:
Type type = Type.GetType("Pages.Page_" + (index).ToString(), true);
dynamic newPage = Activator.CreateInstance(type);
My problem is that I've just learned that the app must be Silverlight 3 and, as a result, it will not be able to use the dynamic type. I've tried changing "dynamic" to "object" but I need to be able to access the XAML on each page and manipulate the XAML. If all I needed was to access properties and methods, I'd be able to follow the solution for creating dynamic objects here.
How can I dynamically create each page and still be able to access the XAML?