开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜