I try to remove an UIElement from the Canvas. But although it is removed from the canvas.Children collection, is still remains drawn on the canvas.
Do you know any solution to this problem?
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.
What you say is not true must be true and so you will have to use tools to resolve the apparent contradiction.
The first and most traditional tool is the debugger. You can literally inspect the
Childrenproperty of theCanvasand see if the element is there even though you think you removed it. This is the “trust but verify” principle. Normally you don’t have to verify common sense things but when you have a contradiction it’s time to start verifying.The second tool, Snoop, is very powerful and ideally suited for your situation:
With this tool you can find the rogue object in the visual tree, see its parent, see its properties, etc. This might convince you that it is indeed still part of the visual tree, but perhaps not where you thought it was.