Check Object type in List of Objects

后端 未结 4 1138
刺人心
刺人心 2021-01-28 13:03

Got a WPF Form with a StackPanel containing Expanders with StackPanels in it.


    

        
4条回答
  •  时光取名叫无心
    2021-01-28 13:29

    Not many questions answer this part of the question. "Now i must know if the list contains an object of type stackpanel." Which can be achieved through the following:

    if (tmpList.Any(x=>x.IsTypeOf(StackPanel)))
    {
         //returns true if there are any stack panels in the list 
    }
    

提交回复
热议问题