1
WPF ListBox
컨트롤에서 ListBox.DataContext
을 업데이트하고 마지막 항목을 하나 선택하려고합니다. 그러나 그것은 실패합니다.ListBox에서 하나의 항목을 선택하는 방법
public void Update_Button_Click()
{
this.MyListBox.BeginInit();
this.MyListBox.DataContext = family; // family is a collection of Person object.
this.MyListBox.EndInit();
this.MyListBox.SelectedIndex = family.Count - 1;
}
그러나 어떤 항목이 목록 상자
<ListBox Name="MyListBox" ItemsSource="{Binding}"/>
내가 SourceUpdated
이벤트 처리기에서 SelectedIndex
를 업데이트하려고 선택하지, 그것은 또한 실패합니다.
예, 다른 모든 코드를 제거한 후에 다시 작동합니다. 선택한 항목의 너비 애니메이션 때문입니다. 나는 다시 시도하고 애니메이션을 할 다른 방법을 찾는다. –