Exemplo n.º 1
0
        private void TryFocusSelectedItem()
        {
            var selectedIndex = SelectedIndex;

            if (IsDropDownOpen && selectedIndex != -1)
            {
                var container = ItemContainerGenerator.ContainerFromIndex(selectedIndex);

                if (container == null && SelectedIndex != -1)
                {
                    ScrollIntoView(Selection.SelectedIndex);
                    container = ItemContainerGenerator.ContainerFromIndex(selectedIndex);
                }

                if (container != null && CanFocus(container))
                {
                    container.Focus();
                }
            }
        }
Exemplo n.º 2
0
        private void UpdateSelectedContent(AvaloniaPropertyChangedEventArgs e)
        {
            var index = (int)e.NewValue;

            if (index == -1)
            {
                SelectedContentTemplate = null;

                SelectedContent = null;

                return;
            }

            var container = (TabItem)ItemContainerGenerator.ContainerFromIndex(index);

            if (container == null)
            {
                return;
            }

            UpdateSelectedContent(container);
        }
Exemplo n.º 3
0
 /// <inheritdoc/>
 void IItemsPresenterHost.RegisterItemsPresenter(IItemsPresenter presenter)
 {
     Presenter = presenter;
     ItemContainerGenerator.Clear();
 }