Assuming you mean the you aquire from the DB the name of the page that you want to determine the name of the page to display.
I'll take the simplest example where all the pages are in a single application assembly and a single known namespace. It can be as simple as this:-
Type pageType = Assembly.GetExecutingAssembly().GetType("SilverlightApplication1." + pageName);
RootVisual = (UIElement)Activator.CreateInstance(pageType);
Perhaps a more flexibable approach would be to store in the database an AssemblyQualifiedName
. That way the page can be in a different assembly and/or namespace, it need only be present in the XAP (I'm not sure whether it can be in a cached assembly library zip). If the page name is an AssemblyQualifiedName
then the code becomes:-
Type pageType = Type.GetType(pageName);
RootVisual = (UIElement)Activator.CreateInstance(pageType);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…