Last active
April 15, 2020 09:19
-
-
Save MwBakker/c7a256e09624866c1f9635ade18a0e88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<DependencyObject> ScanElementsOnMatch(IElementReference elementReference, DependencyObject viewToSearchIn) | |
{ | |
string elementReferenceType = elementReference.Type.Description.ToLower(); | |
int childrenCount = 0; | |
Application.Current.Dispatcher.Invoke(() => { childrenCount = VisualTreeHelper.GetChildrenCount(viewToSearchIn); }); | |
for (var i = 0; i < childrenCount; i++) | |
{ | |
DependencyObject child = null; | |
Application.Current.Dispatcher.Invoke(() => { child = VisualTreeHelper.GetChild(viewToSearchIn, i); }); | |
foreach (DependencyObject meuk in ScanElementsOnMatch(elementReference, child)) | |
{ | |
yield return meuk; | |
} | |
} | |
yield return viewToSearchIn; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment