开发者

How to list pages in Silverlight Application?

开发者 https://www.devze.com 2023-01-24 10:06 出处:网络
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 Silve

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));
0

精彩评论

暂无评论...
验证码 换一张
取 消