You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For an ItemsControl, ItemAutomationPeer is supposed to help link the items' actual automation peers to the automation tree.
However, in certain situation, ItemAutomationPeer doesn't correctly update its Children, resulting in automation peers missing from the tree
This is just a simplified example. In reality, we have many different types of data items, each with its own data template.
Expected behavior
After checking the check box and the button becomes visible, a button automation peer should be available in the automation tree for UI automation tools e.g. Windows Narrator should be able to read the button out when focused on it
Actual behavior
No button automation peers in the automation tree. Windows Narrator isn't able to discover the button
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
No response
Other information
The issue happens when the following conditions are met:
The item containers (ContentPresenter) are initially invisible, and later become visible
The data items are not UIElement
The data items' equality remains the same before and after the visibility is changed
The automation tree is updated after the layout update. When the visibility is changed, the automation tree is invalidated and the automation tree update goes from the top to the bottom. The problem is that ItemAutomationPeer.Children is null while _ancestorsInvalid is false and _childrenValid is true, which prevents it from updating its children when the automation tree is updated.
When an ItemAutomationPeer first attempts to update its children, GetWrapperPeer creates a FrameworkElementAutomationPeer for the ContentPresenter. However, the wrapper peer won't be able to find any child because the ContentPresenter is invisible and doesn't have any visual child. _ancestorsInvalid is false and _childrenValid is set to true after the automation tree update.
When the ContentPresenter become visible, the automation peers call InvalidateAncestorsRecursive during the layout update, but _ancestorsInvalid remains false for the ItemAutomationPeer because no other automation peers can reach it through the ancestry link. Things will be different if the data item is an UIElement, in which case the UIElement's automation peer will be obtained as a wrapper peer and the ancestry link is established via EventSource.
In the subsequent automation tree update, the same ItemAutomationPeer is obtained from the cache, which won't be possible if the data item's equality has changed. Since _ancestorsInvalid is false and _childrenValid is still true for the ItemAutomationPeer, no more children update will happen. It remains having no children
The text was updated successfully, but these errors were encountered:
Description
For an
ItemsControl
,ItemAutomationPeer
is supposed to help link the items' actual automation peers to the automation tree.However, in certain situation,
ItemAutomationPeer
doesn't correctly update itsChildren
, resulting in automation peers missing from the treeReproduction Steps
Can be reproduced with the following XAML
This is just a simplified example. In reality, we have many different types of data items, each with its own data template.
Expected behavior
After checking the check box and the button becomes visible, a button automation peer should be available in the automation tree for UI automation tools e.g. Windows Narrator should be able to read the button out when focused on it
Actual behavior
No button automation peers in the automation tree. Windows Narrator isn't able to discover the button
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
No response
Other information
The issue happens when the following conditions are met:
ContentPresenter
) are initially invisible, and later become visibleUIElement
The automation tree is updated after the layout update. When the visibility is changed, the automation tree is invalidated and the automation tree update goes from the top to the bottom. The problem is that
ItemAutomationPeer.Children
is null while_ancestorsInvalid
is false and_childrenValid
is true, which prevents it from updating its children when the automation tree is updated.When an
ItemAutomationPeer
first attempts to update its children,GetWrapperPeer
creates aFrameworkElementAutomationPeer
for theContentPresenter
. However, the wrapper peer won't be able to find any child because theContentPresenter
is invisible and doesn't have any visual child._ancestorsInvalid
is false and_childrenValid
is set to true after the automation tree update.When the
ContentPresenter
become visible, the automation peers callInvalidateAncestorsRecursive
during the layout update, but_ancestorsInvalid
remains false for theItemAutomationPeer
because no other automation peers can reach it through the ancestry link. Things will be different if the data item is anUIElement
, in which case theUIElement
's automation peer will be obtained as a wrapper peer and the ancestry link is established viaEventSource
.In the subsequent automation tree update, the same
ItemAutomationPeer
is obtained from the cache, which won't be possible if the data item's equality has changed. Since_ancestorsInvalid
is false and_childrenValid
is still true for theItemAutomationPeer
, no more children update will happen. It remains having no childrenThe text was updated successfully, but these errors were encountered: