Trigger SelectedIndex changed whilst clicking on any control within a ListBoxItem area

前端 未结 4 898
广开言路
广开言路 2020-12-18 11:26

I\'ve a data template for ListBoxItem which contains of few buttons, and few custom controls like Grid or Chart. Each button is bound to an appropriate command handler, Sel

4条回答
  •  鱼传尺愫
    2020-12-18 12:11

    XAML-only solution:

    You can adapt the ItemContainerStyle and listen on the trigger is the mousefocus is inside of the Item. It works for all kind of child elements (in this example just mouse focus, which shouldnt be a problem, as the keyboard selects the item automatically too...)

    example:

        
        
          
            test
            test
            test
            test
          
          
        
      
      
      
        
      
    
      
      
      
          

提交回复
热议问题