Exposing TogglePattern on UIItem

Feb 17, 2009 at 3:07 AM
In our application, we have a treeview which contains treenodes, and the tree nodes contain toggle buttons.  To that end, I've had to make changes to the white framework in the following manners:

- TreeNode inherits from UIItemContainer (so that we can get the immediate child buttons)
- UIItem contains code to get the togglestate, and to Toggle the button.

These two additions may be useful to other users of the White framework, as it did help to automate our tree.

In UIItem.cs:

        /// <summary />
        /// Gets the toggle state of the current UI item
        /// 
        public virtual ToggleState ToggleState
        {
            get
            {
                TogglePattern pattern = Pattern(TogglePattern.Pattern) as TogglePattern;
                if (pattern == null)
                    return ToggleState.Indeterminate;
                System.Windows.Automation.TogglePattern.TogglePatternInformation patternInfo = pattern.Current;
                return patternInfo.ToggleState;
            }
        }
        /// <summary />
        /// Toggles the current UI element
        /// 
        public virtual void Toggle()
        {
            TogglePattern pattern = Pattern(TogglePattern.Pattern) as TogglePattern;
            if (pattern == null)
                throw new InvalidOperationException("Object does not support toggle pattern");
            pattern.Toggle();
        }
Coordinator
Feb 18, 2009 at 7:09 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
May 18, 2009 at 7:18 AM

Is there a release plan for 0.18 ?

 

Throndorin

Jun 3, 2009 at 3:00 PM

Hi

 

is toggle now part of release 0.18 or not?

 

I try

 

Tree checkSelectionTree = (Tree)_configureChecksWindows.Get(SearchCriteria.ByAutomationId("checkSelection"));

TreeNode node = checkSelectionTree.Node( "Unused" );

 

now I expect that I can use

 

if(node.ToggleState == "the state")

{

  node.Toggle();

}

But there is no ToggleState and no operation Toggle

 

Throndorin