WPF ComboBox with CompositeCollection - SelectedIndex not sticking

前端 未结 1 1543
我寻月下人不归
我寻月下人不归 2021-01-06 10:52

I\'m using a ComboBox with a CompositeCollection as follows:


    
        
                   


        
1条回答
  •  一个人的身影
    2021-01-06 11:07

    Since you're adding to your Collection after the ComboBox is constructed, you may have to dip into the Loaded event and set your SelectedIndex there...

    
        
            
                
                
            
        
    
    

    Code behind:

    private void ComboBox_Loaded(object sender, RoutedEventArgs e)
    {
        (sender as ComboBox).SelectedIndex = 0;
    }
    

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