0
下面的代碼片段來自Silverlight SDK,我試圖理解它是這樣的原因。 任何人都可以解釋for
循環的需要嗎?Silverlight SDK源代碼中此方法的用途是什麼?
internal static DependencyObject GetVisualRoot(DependencyObject d)
{
DependencyObject root = d;
for (; ;)
{
FrameworkElement element = root as FrameworkElement;
if (element == null)
{
break;
}
DependencyObject parent = element.Parent as DependencyObject;
if (parent == null)
{
break;
}
root = parent;
}
return root;
}