Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/extended tree helpers #4333

Merged

Conversation

Sergio0694
Copy link
Member

@Sergio0694 Sergio0694 commented Oct 21, 2021

Closes #4300

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

Some visual tree helpers are missing, and there is no way to specify the search type.

What is the new behavior?

Added the missing APIs discussed in the issue and listed below.

API breakdown

 namespace Microsoft.Toolkit.Uwp.UI
 {
+    public enum SearchType
+    {
+        DepthFirst,
+        BreadthFirst
+    }

     public static class DependencyObjectExtensions
     {
         public static FrameworkElement? FindDescendant(this DependencyObject element, string name, StringComparison comparisonType = StringComparison.Ordinal);
+        public static FrameworkElement? FindDescendant(this DependencyObject element, string name, StringComparison comparisonType, SearchType searchType);
         public static T? FindDescendant<T>(this DependencyObject element) where T : notnull, DependencyObject;
+        public static T? FindDescendant<T>(this DependencyObject element, SearchType searchType) where T : notnull, DependencyObject;
         public static DependencyObject? FindDescendant(this DependencyObject element, Type type);
+        public static DependencyObject? FindDescendant(this DependencyObject element, Type type, SearchType searchType);
         public static T? FindDescendant<T>(this DependencyObject element, Func<T, bool> predicate) where T : notnull, DependencyObject;
+        public static T? FindDescendant<T>(this DependencyObject element, Func<T, bool> predicate, SearchType searchType) where T : notnull, DependencyObject;
         public static T? FindDescendant<T, TState>(this DependencyObject element, TState state, Func<T, TState, bool> predicate) where T : notnull, DependencyObject;
+        public static T? FindDescendant<T, TState>(this DependencyObject element, TState state, Func<T, TState, bool> predicate, SearchType searchType) where T : notnull, DependencyObject;
         public static FrameworkElement? FindDescendantOrSelf(this DependencyObject element, string name, StringComparison comparisonType = StringComparison.Ordinal);
+        public static FrameworkElement? FindDescendantOrSelf(this DependencyObject element, string name, StringComparison comparisonType, SearchType searchType);
         public static T? FindDescendantOrSelf<T>(this DependencyObject element) where T : notnull, DependencyObject;
+        public static T? FindDescendantOrSelf<T>(this DependencyObject element, SearchType searchType) where T : notnull, DependencyObject;
         public static DependencyObject? FindDescendantOrSelf(this DependencyObject element, Type type);
+        public static DependencyObject? FindDescendantOrSelf(this DependencyObject element, Type type, SearchType searchType);
         public static T? FindDescendantOrSelf<T>(this DependencyObject element, Func<T, bool> predicate) where T : notnull, DependencyObject;
+        public static T? FindDescendantOrSelf<T>(this DependencyObject element, Func<T, bool> predicate, SearchType searchType) where T : notnull, DependencyObject;
         public static T? FindDescendantOrSelf<T, TState>(this DependencyObject element, TState state, Func<T, TState, bool> predicate) where T : notnull, DependencyObject;
+        public static T? FindDescendantOrSelf<T, TState>(this DependencyObject element, TState state, Func<T, TState, bool> predicate, SearchType searchType) where T : notnull, DependencyObject;
         public static IEnumerable<DependencyObject> FindDescendants(this DependencyObject element);
+        public static IEnumerable<DependencyObject> FindDescendants(this DependencyObject element, SearchType searchType);
+        public static IEnumerable<DependencyObject> FindDescendantsOrSelf(this DependencyObject element);
+        public static IEnumerable<DependencyObject> FindDescendantsOrSelf(this DependencyObject element, SearchType searchType);
+        public static IEnumerable<DependencyObject> FindFirstLevelDescendants(this DependencyObject element);
+        public static IEnumerable<DependencyObject> FindFirstLevelDescendantsOrSelf(this DependencyObject element);
         public static FrameworkElement? FindAscendant(this DependencyObject element, string name, StringComparison comparisonType = StringComparison.Ordinal);
         public static T? FindAscendant<T>(this DependencyObject element) where T : notnull, DependencyObject;
         public static DependencyObject? FindAscendant(this DependencyObject element, Type type);
         public static T? FindAscendant<T>(this DependencyObject element, Func<T, bool> predicate) where T : notnull, DependencyObject;
         public static T? FindAscendant<T, TState>(this DependencyObject element, TState state, Func<T, TState, bool> predicate) where T : notnull, DependencyObject;
         public static FrameworkElement? FindAscendantOrSelf(this DependencyObject element, string name, StringComparison comparisonType = StringComparison.Ordinal);
         public static T? FindAscendantOrSelf<T>(this DependencyObject element) where T : notnull, DependencyObject;
         public static DependencyObject? FindAscendantOrSelf(this DependencyObject element, Type type);
         public static T? FindAscendantOrSelf<T>(this DependencyObject element, Func<T, bool> predicate) where T : notnull, DependencyObject;
         public static T? FindAscendantOrSelf<T, TState>(this DependencyObject element, TState state, Func<T, TState, bool> predicate) where T : notnull, DependencyObject;
         public static IEnumerable<DependencyObject> FindAscendants(this DependencyObject element);
+        public static IEnumerable<DependencyObject> FindAscendantsOrSelf(this DependencyObject element);
+        public static bool IsDescendantOf(this DependencyObject child, DependencyObject element);        
+        public static bool IsAscendantOf(this DependencyObject parent, DependencyObject element);
     }
 }

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • New component
    • Pull Request has been submitted to the documentation repository instructions. Link:
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
    • If control, added to Visual Studio Design project
  • Sample in sample app has been added / updated (for bug fixes / features)
  • New major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

@ghost
Copy link

ghost commented Oct 21, 2021

Thanks Sergio0694 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested review from michael-hawker and azchohfi October 21, 2021 18:18
@ghost ghost added the feature request 📬 A request for new changes to improve functionality label Oct 21, 2021
Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial comments, haven't gone through everything yet, but almost lost them accidently, so while I had some just going to send them over. 🙂

@Sergio0694 Sergio0694 marked this pull request as ready for review October 28, 2021 22:35
@ghost ghost added the no-recent-activity 📉 Open Issues that require attention label Nov 13, 2021
@ghost
Copy link

ghost commented Nov 13, 2021

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 30 days of this comment.

@ghost
Copy link

ghost commented Nov 30, 2021

This PR has been marked as "needs attention 👋" and awaiting a response from the team.

@ghost ghost removed the no-recent-activity 📉 Open Issues that require attention label Nov 30, 2021
@michael-hawker michael-hawker added the partner ⏹ Label for issues that are being depended on or blocking Toolkit partners. label Dec 2, 2021
@Sergio0694 Sergio0694 force-pushed the feature/extended-tree-helpers branch from 0b28ee9 to 888ec93 Compare December 20, 2021 12:42
@Sergio0694 Sergio0694 requested a review from Arlodotexe January 3, 2022 14:25
@Sergio0694 Sergio0694 merged commit a629604 into CommunityToolkit:main Jan 4, 2022
@Sergio0694 Sergio0694 deleted the feature/extended-tree-helpers branch January 4, 2022 12:47
@michael-hawker michael-hawker modified the milestones: 8.0, 7.1.3 Aug 23, 2022
@michael-hawker michael-hawker removed this from the 7.1.3 milestone Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extensions ⚡ feature 💡 feature request 📬 A request for new changes to improve functionality improvements ✨ partner ⏹ Label for issues that are being depended on or blocking Toolkit partners.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Improve/extend the visual tree extensions
4 participants