Can I Cast a Generic List by Type??

Posted by CrazyJoe on Stack Overflow See other posts from Stack Overflow or by CrazyJoe
Published on 2010-05-14T17:44:23Z Indexed on 2010/05/14 17:54 UTC
Read the original article Hit count: 217

Filed under:
|
|

NavigatorItem NavItem = (NavigatorItem)cboItems.SelectedItem;

        lblTitle.Text = NavItem.Title;

        RadWrapPanel Panel = new RadWrapPanel();

        Type t = NavItem.ItemsType; //<------ The Type inside my List is here.

        List<???> items = (List<???>)NavItem.Items; // <----Here Is the problem

        foreach (object item in items)
        {
              Panel.Children.Add((UIElement)Activator.CreateInstance(NavItem.Display,item));
        }

        ItemsContainer.Content = Panel;

In code above i need to get the type of items on t variable to put into of my generic List.

Help Please!!!

© Stack Overflow or respective owner

Related posts about c#

Related posts about generics