Am using the below function to get the topmost parent in my application.
private DependencyObject GetTopParent()
{
DependencyObject dpParent = this.Parent;
do
{
dpParent = LogicalTreeHelper.GetParent(dpParent);
} while (dpParent.GetType().BaseType != typeof(Window));
return dpParent as DependencyObject;
}
How to get all the UI Element or children into a stackpanel??? Like
StackPanel parentControl = this.Parent as StackPanel;