Skip to content

Instantly share code, notes, and snippets.

@judismith
Last active December 31, 2020 16:00
Show Gist options
  • Save judismith/397bcaeef94eff87a2c90fc5535ddd6b to your computer and use it in GitHub Desktop.
Save judismith/397bcaeef94eff87a2c90fc5535ddd6b to your computer and use it in GitHub Desktop.
Xamarin : Method to find ascendant parent of type T of a control.
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