Skip to content

Commit

Permalink
Merge pull request #2090 from arpitmathur/dev/arpit/menuautomationpeer
Browse files Browse the repository at this point in the history
Removing separators from SizeOfSet and PositionInSet counts
  • Loading branch information
arpitmathur authored Oct 29, 2019
2 parents 2da6b1e + 970bb33 commit be31d18
Showing 1 changed file with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ override public object GetPattern(PatternInterface patternInterface)


return result;
}

}

/// <summary>
/// Gets the size of a set that contains this MenuItem.
/// </summary>
Expand All @@ -94,14 +94,22 @@ override public object GetPattern(PatternInterface patternInterface)
override protected int GetSizeOfSetCore()
{
int sizeOfSet = base.GetSizeOfSetCore();

if (sizeOfSet == AutomationProperties.AutomationSizeOfSetDefault)
{
MenuItem owner = (MenuItem)Owner;
MenuItem owner = (MenuItem)Owner;
ItemsControl parent = ItemsControl.ItemsControlFromItemContainer(owner);

sizeOfSet = ItemAutomationPeer.GetSizeOfSetFromItemsControl(parent, owner);
}
sizeOfSet = ItemAutomationPeer.GetSizeOfSetFromItemsControl(parent, owner);

foreach (var item in parent.Items)
{
if (item is Separator)
{
sizeOfSet -= 1;
}
}
}

return sizeOfSet;
}
Expand All @@ -118,13 +126,26 @@ override protected int GetSizeOfSetCore()
override protected int GetPositionInSetCore()
{
int positionInSet = base.GetPositionInSetCore();

if (positionInSet == AutomationProperties.AutomationPositionInSetDefault)
{
MenuItem owner = (MenuItem)Owner;
MenuItem owner = (MenuItem)Owner;
ItemsControl parent = ItemsControl.ItemsControlFromItemContainer(owner);
positionInSet = ItemAutomationPeer.GetPositionInSetFromItemsControl(parent, owner);
}

positionInSet = ItemAutomationPeer.GetPositionInSetFromItemsControl(parent, owner);

foreach (var item in parent.Items)
{
if (item == owner)
{
break;
}
if (item is Separator)
{
positionInSet -= 1;
}
}
}

return positionInSet;
}
Expand Down

0 comments on commit be31d18

Please sign in to comment.