GridView DoubleClick

前端 未结 3 1623
温柔的废话
温柔的废话 2020-12-18 12:25

I have a GridView where I want to detect a doubleclick event on the items in the list, i do it as follows:


    
               


        
3条回答
  •  自闭症患者
    2020-12-18 13:24

    For those here that are using a framework like Prism where the main usercontrol containing the Listview is a View (not a window) that is bound to a viewmodel.

    The answer of dlf is the best with these small tweaks:

    {Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, 
             Path=DataContext.SayHiCommand}
    

    And in the special behavior attached property you change the ICommand cast to a DelegateCommand cast.

    Works like a charm, Thank you very much.

提交回复
热议问题