これは簡単なことだと思いますが、大変な時間を過ごしています。
C#でListBoxのscrollviewerへの参照を取得するにはどうすればよいですか?私は考えられるほとんどすべてを試しました。ListBoxはWPFカスタムコントロール内にあるため、Template.FindNameを使用してすべてのコントロールへの参照を取得します。私のリストボックスは次のようになります。
<ListBox x:Name="PART_SoundList"
ScrollViewer.CanContentScroll="False"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Hidden" Focusable="False" FocusVisualStyle="{x:Null}"
HorizontalAlignment="Center" VerticalAlignment="Bottom" BorderThickness="0"
ItemContainerStyleSelector="{StaticResource ListBoxItemAlternatingStyleSelector}"
ItemsSource="{Binding}" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical" Height="850" Focusable="False" Panel.ZIndex="999" >
<WrapPanel.RenderTransform>
<TransformGroup>
<ScaleTransform CenterX="0" CenterY="0" ScaleX=".75" ScaleY=".57" />
</TransformGroup>
</WrapPanel.RenderTransform>
</WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Template>
<ControlTemplate>
<ScrollViewer x:Name="Scroller" VerticalAlignment="Bottom" Focusable="False" Style="{StaticResource HorizontalScroller}" >
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Focusable="False" Panel.ZIndex="999" />
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
</ListBox>
Template.FindName( "Scroller"、this)asScrollViewerはnullになります。
何か案は?