void itemContainerGenerator_StatusChanged(object sender, EventArgs e) { ItemContainerGenerator generator = sender as ItemContainerGenerator; if (generator == null) { return; } if (generator.Status != System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated) { return; } generator.StatusChanged -= itemContainerGenerator_StatusChanged; TreeListViewItem ti = (generator.ContainerFromItem(__NoteToMakeActive) as TreeListViewItem); if (ti == null) { __NoteToMakeActive = null; } else { ti.Focus(); if (__ColumnIdxToFocus == -1) { MakeActiveDone(__NoteToMakeActive, null); __NoteToMakeActive = null; } else { MyEdit editor = ti.GetEditor(GetViewLastEditorColumnId(), GetLastEditorColumnId(), __ColumnToFocusIsInline) as MyEdit; if (editor != null) { Keyboard.Focus(editor); MakeActiveDone(__NoteToMakeActive, editor); __NoteToMakeActive = null; } else { __TviToMakeActive = ti; ti.LayoutUpdated += new EventHandler(ti_LayoutUpdated); } } } }
private void FocusEditorForSelectedRow() { if (SelectedItem != null) { ItemContainerGenerator itemGenerator = ItemContainerGeneratorFor(SelectedItem); //BUG: Почему здесь иногда бывает null - не ясно if (itemGenerator != null) { TreeListViewItem li = itemGenerator.ContainerFromItem(SelectedItem) as TreeListViewItem; if (li != null) { MyEdit edit = li.GetEditor(GetViewLastEditorColumnId(), GetLastEditorColumnId(), false) as MyEdit; if (edit != null) { Keyboard.Focus(edit); } } } } }