<Hub>
<HubSection Header="学生计划">
<HubSection.ContentTemplate>
<DataTemplate>
<ScrollViewer>
<StackPanel>
<WebView Name="webview1"></WebView>
</StackPanel>
</ScrollViewer>
</DataTemplate>
</HubSection.ContentTemplate>
</HubSection>
</Hub>
可以通过视觉树遍历的方式来查找,类似的辅助类如:visualTreeHelper
例如下面这段代码,就是我以前pro使用过的:
public static Visual FindDescendantByName(Visual element, string name) { if (element == null) { return null; } if (element is FrameworkElement && (element as FrameworkElement).Name == name) { return element; } Visual visual = null; if (element is FrameworkElement) { (element as FrameworkElement).ApplyTemplate(); } for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++) { Visual element2 = VisualTreeHelper.GetChild(element, i) as Visual; visual = VisualTreeHelperEx.FindDescendantByName(element2, name); if (visual != null) { break; } } return visual; }