/// <summary> /// Focus the first item in the TreeView. /// </summary> /// <returns>A value indicating whether the item was focused.</returns> private bool FocusFirstItem() { // Get the first item in the TreeView. TreeViewItem item = ItemContainerGenerator.ContainerFromIndex(0) as TreeViewItem; return((item != null) ? (item.IsEnabled && item.Focus()) || item.FocusDown() : false); }