private static Control GetParentOrDefault <T>(System.Windows.Controls.Grid grid)
     where T : Control
 {
     return(grid.Ancestors()
            .OfType <T>()
            .FirstOrDefault());
 }