WPF Controls are divided into various baskets. Some controls belong to System.Windows.Controls namespace and other belong to Panel and other stuff. I am interested in getting the control as a Panel or Control type so I can change the Background property. The following code is not working:
var element = ((sender as Panel) ?? (sender as Control));