private void btnBack_Click(object sender, RoutedEventArgs e) { if (this.Parent != null) { UIElementCollection children = ((Panel)this.Parent).Children; if (children.Contains(this)) { children.Remove(this); } } }