Last active
December 31, 2020 16:00
-
-
Save judismith/397bcaeef94eff87a2c90fc5535ddd6b to your computer and use it in GitHub Desktop.
Xamarin : Method to find ascendant parent of type T of a control.
This file contains hidden or 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
private static T GetParentControl<T>(View control) where T : SfTextInputLayout | |
{ | |
if (control == null) return null; | |
var parent = control.Parent; | |
while (parent != null) | |
{ | |
if (parent is T) return parent as T; | |
parent = parent.Parent; | |
} | |
return null; | |
} | |
// Hat Tip: http://taoffi.isosoft.org/post/2016/03/17/Xamarin-forms-Traversing-the-View-tree |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment