0
가로 ListBox를 만들고 바인딩 된 데이터로 채우고 화면의 "외부"에있는 기본 항목을 설정했습니다. 그 후에 ScrollIntoView 메서드를 호출했지만 아무 일도 일어나지 않습니다. 나는 무엇을 잘못 했는가?ScrollIntoView 메서드가 가로 ListBox에서 작동하지 않습니다.
내 XAML (나는 문제가 여기 어딘가에 생각)의관련 부분 :
이<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Template>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled">
<ItemsPresenter x:Name="itemsPresenter" />
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
그리고 C# 코드 : 이름 = "에서 ScrollViewer : 당신은 ControlTemplate에서
reservationsListBox.SelectedIndex = 40;
reservationsListBox.ScrollIntoView(reservationsListBox.Items[reservationsListBox.SelectedIndex]);
나는 귀하의 솔루션을 시도하고 처음으로 아무것도하지 않았다. 이후, reservationsList.UpdateLayout()을 reservationListBox.ScrollIntoView 부분 바로 앞에 호출했습니다. 이제는 내 목록 상자를 "어딘가에"(선택한 항목에 더 가깝게) 스크롤하지만 여전히 화면 외부에 있기 때문에 선택한 항목을 볼 수 없습니다. – bazsibazsi
여기에 포함 된 스 니펫을 넘어서는 또 다른 내용입니다. 내 생각 엔 ListBox 자체가 화면보다 큽니다. ScrollIntoView는 항목을 ListBox로 스크롤하지만 (아마 하단) ListBox를 화면에 강제로 표시하지는 않습니다. –
안녕히 계십시오, 당신의 충고가 저의 원래 문제를 해결했습니다! – bazsibazsi