2010-07-20 2 views
1

선택에 따라 srollviewer 안에있는 목록 상자를 스크롤하고 싶습니다.목록 상자에서 목록 상자 항목을 가져 오는 방법 wpf

ListBoxItem item = (ListBoxItem)(lbTrack.ItemContainerGenerator.ContainerFromItem(lbTrack.Items.CurrentItem)); 

     // ListBoxItem item = (ListBoxItem)(lbTrack.ItemContainerGenerator.ContainerFromItem(lbTrack.SelectedItem)); 
     if (item != null) 
     { 
      item.BringIntoView(); 
     } 

그러나 null 값을 제공합니다.

답변

1

희망이 도움이 : 코드 아래

if (listView.SelectedItem != null) 
{ 
    listView.ScrollIntoView(listView.SelectedItem); 
} 
0

시도

Dispatcher.CurrentDispatcher.BeginInvoke((ThreadStart)delegate 
    { 
     item.BringToView(); 
    }, DispatcherPriority.Normal, null);