PhoneCode pc = new PhoneCode(); pc.OK += Pc_OK; grid.Children.Add(pc); Panel.SetZIndex(pc, grid.Children.Count + 1);