I register for a callback notification on a DependencyProperty of type MyObject. In the function, I do a cast from DependencyObject to my expected type of MyObject. Will this ever return null? Can I safely remove the null check from my code?
private static void OnMyObjectChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
MyObject obj = d as MyObject;
if (obj != null) // Is this check needed? Will it ever be null?
{
...
}
}