How to list pages in Silverlight Application?
I want to list all pages in application and create instance of these pages prog开发者_如何学运维ramatically. If you have any idea about this please help. Thanks..
I assume you are talking about a Silverlight Navigation application?
If you need to get all types that inherit from System.Windows.Controls.Page in your app you can use:
var pageTypes = typeof(App)
.Assembly
.GetTypes()
.Where(type => typeof(Page).IsAssignableFrom(type));
Then you can iterate over this to get instances of each:
var instances = types.Select(type => Activator.CreateInstance(type));
精彩评论