Listbox “IsSelected” binding only partially working

前端 未结 1 555
独厮守ぢ
独厮守ぢ 2021-01-13 08:15

I have a ListBox that I populate dynamically via a binding (this is defined in a DataTemplate, which is why the binding is somewhat unusual):

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-13 09:17

    I think the behavior you're seeing is to due to VirtualizingStackPanel.IsVirtualizing which is True by default when binding to ItemsSource of ListBox

    if you for eg set your ListBox such as:

    
    

    or

    
      ...
      
        
          
        
      
    
    

    then you should see all your bound items have their IsSelected updated accordingly with Ctrl+A or Shift + ...

    Properties such as Count of the collection even with virtualization would report the correct value to accommodate for things like computing the required ScrollBar.Height. Items which are outside the View-port do not get rendered hence no bindings are in effect on them until they actually get used.

    0 讨论(0)
提交回复
热议问题