public void FocusItem(MultiTagModelItem i) { Debug.Assert(i != null); focusItem = i; if (ItemContainerGenerator.ContainerFromItem(focusItem) != null) { DoFocusItem(); } }
private void DoFocusItem() { Debug.Assert(focusItem != null); ContentPresenter contentPresenter = (ContentPresenter) ItemContainerGenerator.ContainerFromItem(focusItem); if (contentPresenter.IsLoaded) { Keyboard.Focus(WpfUtils.FindVisualChild <TextBox>(contentPresenter)); focusItem = null; } else { contentPresenter.Loaded += delegate(object obj, RoutedEventArgs e) { Keyboard.Focus(WpfUtils.FindVisualChild <TextBox>(contentPresenter)); focusItem = null; }; } }