Inheritance: System.Windows.Automation.Peers.SelectorAutomationPeer, IValueProvider, IExpandCollapseProvider
        /// <summary>This type or member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.</summary>
        // Token: 0x0600276F RID: 10095 RVA: 0x000BA020 File Offset: 0x000B8220
        void IScrollItemProvider.ScrollIntoView()
        {
            ListBox listBox = base.ItemsControlAutomationPeer.Owner as ListBox;

            if (listBox != null)
            {
                listBox.ScrollIntoView(base.Item);
                return;
            }
            ComboBoxAutomationPeer comboBoxAutomationPeer = base.ItemsControlAutomationPeer as ComboBoxAutomationPeer;

            if (comboBoxAutomationPeer != null)
            {
                comboBoxAutomationPeer.ScrollItemIntoView(base.Item);
            }
        }
        void IScrollItemProvider.ScrollIntoView()
        {
            ListBox parent = ItemsControlAutomationPeer.Owner as ListBox;

            if (parent != null)
            {
                parent.ScrollIntoView(Item);
            }
            else
            {
                ComboBoxAutomationPeer parentPeer = ItemsControlAutomationPeer as ComboBoxAutomationPeer;
                if (parentPeer != null)
                {
                    parentPeer.ScrollItemIntoView(Item);
                }
            }
        }
Exemplo n.º 3
0
        public static void SetWidthFromItems(this ComboBox comboBox)
        {
            double comboBoxWidth = 19;// comboBox.DesiredSize.Width;

            // Create the peer and provider to expand the comboBox in code behind.
            ComboBoxAutomationPeer peer = new ComboBoxAutomationPeer(comboBox);
            IExpandCollapseProvider provider = (IExpandCollapseProvider)peer.GetPattern(PatternInterface.ExpandCollapse);
            EventHandler eventHandler = null;
            eventHandler = new EventHandler(delegate
            {
                if (comboBox.IsDropDownOpen &&
                    comboBox.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
                {
                    double width = 0;
                    foreach (var item in comboBox.Items)
                    {
                        ComboBoxItem comboBoxItem = comboBox.ItemContainerGenerator.ContainerFromItem(item) as ComboBoxItem;
                        comboBoxItem.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                        if (comboBoxItem.DesiredSize.Width > width)
                        {
                            width = comboBoxItem.DesiredSize.Width;
                        }
                    }
                    comboBox.Width = comboBoxWidth + width;
                    // Remove the event handler.
                    comboBox.ItemContainerGenerator.StatusChanged -= eventHandler;
                    comboBox.DropDownOpened -= eventHandler;
                    provider.Collapse();
                }
            });
            comboBox.ItemContainerGenerator.StatusChanged += eventHandler;
            comboBox.DropDownOpened += eventHandler;
            // Expand the comboBox to generate all its ComboBoxItem's.
            provider.Expand();
        }
Exemplo n.º 4
0
        //public string i9DrowndownType
        //{
        //    get { return (string)base.GetValue(i9DrowndownTypeProperty); }
        //    set { base.SetValue(i9DrowndownTypeProperty, value); }
        //}

        //public string i9BindColumn
        //{
        //    get { return (string)base.GetValue(i9BindColumnProperty); }
        //    set { base.SetValue(i9BindColumnProperty, value); }
        //}


        protected override void OnGotFocus(System.Windows.RoutedEventArgs e)
        {
            base.OnGotFocus(e);
            ComboBoxAutomationPeer peer = new ComboBoxAutomationPeer(this);
            List<AutomationPeer> children = peer.GetChildren();

            if (children != null && children.Count == 1 && children[0] is TextBoxAutomationPeer)
            {
                ((TextBox)((TextBoxAutomationPeer)children[0]).Owner).MaxLength = maxLength;
            }
        }