binding - ListBoxItem with ContextMenu item to Command -


i'm using contextmenu microsoft.phone.controls.toolkit:

xmlns:toolkit="clr-namespace:microsoft.phone.controls;assembly=microsoft.phone.controls.toolkit" 

and want delete listboxitem via deletecommand

<listbox itemssource="{binding items}">      <listbox.itemcontainerstyle>         <style targettype="listboxitem">             <setter property="horizontalcontentalignment" value="stretch"/>         </style>     </listbox.itemcontainerstyle>      <listbox.itemtemplate>         <datatemplate>             <grid>                 <toolkit:contextmenuservice.contextmenu>                     <toolkit:contextmenu >                         <toolkit:menuitem header="delete" command="{binding deletecommand}" commandparameter="????"/>                     </toolkit:contextmenu>                 </toolkit:contextmenuservice.contextmenu>                 <grid.columndefinitions>                     <columndefinition width="*" />                     <columndefinition width="auto" />                 </grid.columndefinitions>                 <textblock text="{binding name}" horizontalalignment="left" verticalalignment="center" textwrapping="wrap"/>                 <toolkit:toggleswitch  grid.column="1" horizontalalignment="right" verticalalignment="center"/>             </grid>         </datatemplate>     </listbox.itemtemplate> </listbox> 

deletecommand:

public icommand deletecommand {         {         return new mvxcommand<bulbitem>(item =>         {             _collectionservice.delete(item);             close(this);         });     } } 

how pass listboxitem bound list of bulbitems deletecommand?

thanks in advance!

i think might able replace ???? {binding} - in case path implicit binding object in datacontext itself


beyond that, you'll need route deletecommand binding parent object's datacontext - think can using kind of elementname or relativesource binding - i'm not expert on this.

generally put commands inside list item objects - e.g. see of answer in mvvmcross changing viewmodel within mvxbindablelistview


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -