How to convert List to List WPF

后端 未结 1 1303
栀梦
栀梦 2021-01-20 04:10

Lets say I have a Listbox


I have a Property:

private List          


        
相关标签:
1条回答
  • 2021-01-20 04:28

    I think that your issue caused by covariance/contrvariance. Classes don't support this feature. You can use interface or Cast linq method. See more here: https://msdn.microsoft.com/en-us/library/ee207183.aspx I mean something like this:

    MyList = GetListAFromSomewhere().Cast<dynamic>().ToList();
    

    Also not sure if your ListBox will work properly with dynamic. You could use inheritance and TemplateSelector in XAML: http://www.codeproject.com/Articles/418250/WPF-Based-Dynamic-DataTemplateSelector

    0 讨论(0)
提交回复
热议问题