我試圖訪問下面的XAML中名爲'ScrollViewerItems'的ScrollViewer,並在後面的代碼中使用它。該名稱似乎並未被識別,可能是因爲它嵌入在ItemsControl中。我不需要指定的訪問權限,但是如何在代碼後面訪問ItemsControl的ScrollViewer?如何訪問ItemsControl中的ScrollViewer
<ItemsControl x:Name="EnteredItemsView" ItemsSource="{Binding LineItems}" VirtualizingStackPanel.IsVirtualizing="True" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer x:Name="ScrollViewerItems" Focusable="False">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
...
您可以使用可視化樹幫手還是可以的或templatedchild – JSJ 2013-02-13 15:08:19