Given UIElementCollection, find all elements that have StyleA, and change them to StyleB in WPF

回眸只為那壹抹淺笑 提交于 2019-12-03 00:35:02

Your code was almost correct, but UIElements don't have a Style property... You can filter the grid's children based to their type :

var recs = from r in MyGrid.Children.OfType<Rectangle>()
           where r.Style == StyleA
           select r;

foreach(Rectangle r in recs)
   r.Style = StyleB;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!