c# - Is it possible to access a property from the control's view model from a listview item template? -


i creating feature navigate through menu items given breadcrumbs go back. in order create in windows 8 app, generating collection of items , adding on collection navigate through menu.

the xaml code displaying breadcrumbs is:

<listview verticalalignment="top"           horizontalalignment="left"           margin="120,60,0,0"           itemssource="{binding parents}">     <listview.itemspanel>         <itemspaneltemplate>             <stackpanel orientation="horizontal"/>         </itemspaneltemplate>     </listview.itemspanel>     <listview.itemtemplate>         <datatemplate>             <stackpanel orientation="horizontal">                 <textblock text=">>" />                 <button content="{binding name}" command="{binding opencommand}" commandparameter="{binding}" />             </stackpanel>         </datatemplate>     </listview.itemtemplate> </listview> 

while works, not 100% happy bindings of button. problem invoking functionality , running on overall control's view model, , seems require me have opencommand property on inner item command.

is possible bind button's command= attribute command on control's overall view model, instead of list item itself?

it should possible this:

<listview x:name="listview" ...>     <listview.itemtemplate>         <datatemplate>             <stackpanel orientation="horizontal">                 <textblock text=">>" />                 <button content="{binding name}"                     command="{binding datacontext.opencommand, elementname=listview}"                     commandparameter="{binding}" />             </stackpanel>         </datatemplate>     </listview.itemtemplate>     ... </listview> 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -