public static int GetItemCount(IntPtr controlHandle)
        {
            try
            {
                AutomationElement control = CommonUIAPatternHelpers.Prologue(SelectionPattern.Pattern, controlHandle);
                int ret = SelectionItemPatternHelper.GetListItemCount(control);

                if (ret == -1)
                {
                    if (control.Current.ControlType == ControlType.ComboBox)
                    {
                        ProdComboBoxNative.GetItemCountNative(controlHandle);
                    }
                    else
                    {
                        ProdListBoxNative.GetItemCountNative(controlHandle);
                    }
                }

                LogController.ReceiveLogMessage(new LogMessage(ret.ToString(CultureInfo.InvariantCulture)));
                return(ret);
            }
            catch (InvalidOperationException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ElementNotAvailableException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ArgumentException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
        }
        private static int NativeGetItemCount(BaseProdControl control)
        {
            if (control.UIAElement.Current.ControlType == ControlType.Tab)
            {
                return(ProdTabNative.GetTabCount((IntPtr)control.UIAElement.Current.NativeWindowHandle));
            }
            if (control.UIAElement.Current.ControlType == ControlType.ComboBox)
            {
                ProdComboBoxNative.GetItemCountNative((IntPtr)control.UIAElement.Current.NativeWindowHandle);
            }

            return(ProdListBoxNative.GetItemCountNative((IntPtr)control.UIAElement.Current.NativeWindowHandle));
        }