c# - Can't detect Right Click on listBox in MVVM -


i don't understand why can't detect right click on list box when use mvvm. use event trigger events doesn't work.

<listbox x:name="playlistslist" itemssource="{binding playlistslist}" horizontalalignment="left">         <i:interaction.triggers>             <i:eventtrigger eventname="mouserightbuttondown">                 <i:invokecommandaction command="{binding newplaylistcommand}"/>             </i:eventtrigger>         </i:interaction.triggers> </listbox> 

my command "newplaylistcommand" never call. me ? thank you.

edit: found solution problem, used contextmenu interact listboxitem

<listbox.itemtemplate>             <datatemplate>                 <stackpanel x:name="listbox">                     <textblock text="{binding name}"/>                     <stackpanel.contextmenu>                         <contextmenu>                             <menuitem header="rename" command="{binding renameplaylistcommand}"/>                             <menuitem header="delete" command="{binding deleteplaylistcommand}" commandparameter="{binding selectedvalue, elementname=playlistslist}"/>                         </contextmenu>                     </stackpanel.contextmenu>                 </stackpanel>             </datatemplate> </listbox.itemtemplate> 

now can right click on item rename or delete it. thank help.

most inside has swallowed right click event , hence has not bubbled (i suspect has context menu behaviors). use preview- events bubble other way.

the other solution use directly apply interaction each , every child in list box (and children well).

however don't expect ui point of view right clicking on play list create new play list...i expect years of windows usage context menu should pop up, possibly "add new play list" menuitem.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -