Microsoft 开发人员网络 > 论坛主页 > Windows Presentation Foundation (WPF) > When does ItemsControl.ItemContainerGenerator generate ListBox items?
提出问题提出问题
 

已答复When does ItemsControl.ItemContainerGenerator generate ListBox items?

  • 2009年7月3日 21:06knji 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    I have a ListBox that is initially Collapsed.  When a user clicks on a checkbox, the ListBox becomes Visible.  I want to programmatically select items the user had selected before when the ListBox is Loaded or becomes Visible.

    However, the ItemsContainerGenerator is returning null for this data items, container, unless the ListBox was not initially Collapsed.

    I have tried selecting the ListBox items programmatically within the Loaded and IsVisibleChanged event handlers but ItemsContainerGenerator is still returning null.

    Any other suggestions?

    TIA.

答案

全部回复