1

In .NET Framework 4.7.1, ListBoxItem.OnCreateAutomationPeer() returns a ListBoxItemWrapperAutomationPeer.

Does anybody know why it does not return a ListBoxItemAutomationPeer? It would be much more usefull since ListBoxItemWrapperAutomationPeer does not do anything but ListBoxItemPeer allows Selection pattern.

g t
  • 7,287
  • 7
  • 50
  • 85
jchristin
  • 7,352
  • 2
  • 15
  • 18

1 Answers1

1

I just found the answer in the internal comments of the class AutomationPeer:

// For ItemsControls, there are typically two different peers for each
// (visible) item:  an "item" peer and a "wrapper" peer.  The former
// corresponds to the item itself, the latter to the container.  (These
// are different peers, even when the item is its own container.)  The item
// peer appears as a child of the ItemsControl's peer, while the wrapper
// peer is what you get by asking the container for its peer directly.
// For example, a ListBoxAutomationPeer holds children of type
// ListBoxItemAutomationPeer, while the peer for a ListBoxItem has type
// ListBoxItemWrapperAutomationPeer.

see https://referencesource.microsoft.com/#PresentationCore/Core/CSharp/System/Windows/Automation/Peers/AutomationPeer.cs,1350

jchristin
  • 7,352
  • 2
  • 15
  • 18