我正在尝试在下面的 XAML 中访问名为“ScrollViewerItems”的 ScrollViewer,并在后面的代码中使用它。该名称似乎无法识别,可能是因为它嵌入在 ItemsControl 中。我不需要命名访问,但是如何在后面的代码中访问 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>
...