private FrameworkElement FindControlParent(FrameworkElement control)
{
FrameworkElement ctrlParent = control;
//check is it user cotrol
while (typeof(UserControl) != null)
{
//get current control parent
ctrlParent = (FrameworkElement)ctrlParent.Parent;
//check current control has no parent; If not then it is the ancestor of my sending control last parent
if (ctrlParent.Parent == null)
{
return (FrameworkElement)ctrlParent;
}
}
return null;
}
No comments:
Post a Comment