Skip to content

Conversation

petvetbr
Copy link
Contributor

@petvetbr petvetbr commented Mar 1, 2016

Improved automation support with AutomationId and Name automatically set according with control Name property.

Following @xxMUROxx sugestion on issue #2381:

Implemented an AutomationHelper, so that the AutomationId and Name are setted based on the Name of the Control for most of the custom controls components. The goal is to eventually obtain full automation coverage for UI Automated Testing and Accessibility purposes.
#2381

@punker76
Copy link
Member

punker76 commented Mar 1, 2016

@petvetbr you don't use the latest source from develop branch

@michaelmairegger
Copy link
Contributor

I have looked into it a bit and found that the UI Elements should get exposed by AutomationPeer Class. So it is done with ButtonAutomationPeer, TextBoxAutomationPeer.

Therefore I think it should be done also with NumericUpDown. Create a class NumericUpDownAutomationPeer and implement the exposure there

UI Automation of a WPF Custom Control

If the default behavior is the one shown in the link above I think we should follow this guidances.

See example at TextBlock and TextBlockAutomationPeer

Furthermore I think the by this PR used attached properties should be used on third party controls, when overriding the template. Since we own this code we should use the suggestion from microsoft and implement XXXAutomationPeer classes for the MahApps controls.

/cc @punker76

@michaelmairegger
Copy link
Contributor

I have tried it with DateTimePicker of MahApps

public class DateTimePickerAutomationPeer : FrameworkElementAutomationPeer
    {
        public DateTimePickerAutomationPeer(DateTimePicker owner)
            : base(owner)
        {
        }

        private DateTimePicker OwningDateTimePicker
        {
            get { return Owner as DateTimePicker; }
        }

        protected override List<AutomationPeer> GetChildrenCore()
        {
            List<AutomationPeer> peers = new List<AutomationPeer>();
            var peer = CreatePeerForElement(OwningDateTimePicker._button);
            if (peer != null)
            {
                peers.Add(peer);
            }
            peer = CreatePeerForElement(OwningDateTimePicker.SecondInput);
            if (peer != null)
            {
                peers.Add(peer);
            }
            return base.GetChildrenCore();
        }
    }

To work the controls like _secondInput in DateTimePicker must be exposed as internal property SecondInput.

According that I suggest to revert #2381 to use the default design provided by Microsoft.

@petvetbr
Copy link
Contributor Author

petvetbr commented Mar 3, 2016

@xxMUROxx Ok. I'll start implementing automation peers for the controls. The first solution I proposed was faster to implement, but you are right, we should try to follow the same patterns recomended by MS and when ready I'll submit a new PR.

@punker76
Copy link
Member

punker76 commented Mar 8, 2016

@petvetbr I close this and will wait for a new PR, thx

@punker76 punker76 closed this Mar 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants