public void DeleteItem(MyTreeViewItem item) { if (item == FocusedItem) { int index = item.GetIndex(); if (index + 1 < GetItemCount()) { FocusedItem = GetItem(index + 1); } else if (index - 1 >= 0) { FocusedItem = GetItem(index - 1); } else { FocusedItem = FocusedItem.Parent as MyTreeViewItem; } } m_body.DeleteItem(item); }