Esempio n. 1
0
        public void FocusItem(MultiTagModelItem i)
        {
            Debug.Assert(i != null);

            focusItem = i;

            if (ItemContainerGenerator.ContainerFromItem(focusItem) != null)
            {
                DoFocusItem();
            }
        }
Esempio n. 2
0
        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;
                };
            }
        }