In Silverlight 3.0 I have added a custom behavior to some UIElement in Code Behind.
I wanted to remove the Behavior later in runtime.
What is the C# syntax to Detach an already added Behavior from an UIElement?
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.
I am guessing you are talking about a behavior deriving from the
Behavior<T>class in the Blend SDK…Do you still have a reference to the behavior from when you attached it?
EDIT
If you no longer have a reference to the instance of the behavior when you want to detach it you can do something like this to detach all behaviors on a DependencyObject: