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
In WPF where Templates are used heavily it is often the case that the easiest way to find something is by text and as a result we have some kind of Label, which is not very useful. It'd be great to have either a way to obtain a parent of given UIItem or at least to have API to obtain not only search target, but also entire path of UIItems in automation elements hierarchy that leads to that search target.
For example, if I have custom data template for ListBoxItem or TreeViewItem - I have "list item"/"tree item" as containers and icon plus label underneath. Without API for getting parent item - it is not easy to obtain UIItem for "tree item" - e.g. if I want to expand it - because it has no distinguished properties like its child label.
The text was updated successfully, but these errors were encountered:
For the moment you could use this extension method
public static class UIItemExtensions
{
public static T GetParent<T>(this IUIItem uiItem) where T : IUIItem
{
var parent = TreeWalker.ControlViewWalker.GetParent(uiItem.AutomationElement);
var uiItem = new DictionaryMappedItemFactory().Create(parent, uiItem.ActionListener);
return UIItemProxyFactory.Create(uiItem, uiItem.ActionListener);
}
}
You can also use the ControlViewWalker to get different controls around it.
In WPF where Templates are used heavily it is often the case that the easiest way to find something is by text and as a result we have some kind of Label, which is not very useful. It'd be great to have either a way to obtain a parent of given UIItem or at least to have API to obtain not only search target, but also entire path of UIItems in automation elements hierarchy that leads to that search target.
For example, if I have custom data template for ListBoxItem or TreeViewItem - I have "list item"/"tree item" as containers and icon plus label underneath. Without API for getting parent item - it is not easy to obtain UIItem for "tree item" - e.g. if I want to expand it - because it has no distinguished properties like its child label.
The text was updated successfully, but these errors were encountered: