I have a WPF Panel (like Canvas for example) and I want to remove its Children only if these children are of type T, for example all of type Button.
How can I do this? Can I use LINQ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use LINQ, this is one way of doing.
OR you can loop though all the Child elements and if it is button add them to a list and finally remove them. don’t remove buttons inside foreach loop.
LINQ way is more readable and simple and less coding.