I have a behavior which I would like to attach to multiple controls and based on their type, I would like to write the logic and for this I need to determine the type of the associated object at runtime and I was wondering how can I do that
class CustomBehavior:Behavior<DependencyObject>
{
protected override void OnAttached()
{
base.OnAttached();
if(AssociatedObject.GetType()==typeof(TextBox))
{
//Do Something
}
else if(AssociatedObject.GetType()==typeof(CheckBox))
{
//Do something else
}
//....
//...
else
//Do nothing
}
}
Will this work?