c# - XAML Binding from ItemsControl Template -


i have view has viewmodel set datacontext. viewmodel has boolean property, call "isineditmode". how bind usercontrol in datatemplate (marked "binding isineditmode") viewmodel on outside?

<itemscontrol itemtemplate="{staticresource homeitemtemplate}">     <itemscontrol.resources>         <datatemplate x:key="homeitemtemplate">             <utils:persontextbox property="{binding isineditmode}"/>         </datatemplate>     </itemscontrol.resources> </itemscontrol> 

you can use relativesource binding outer itemscontrol, , bind data context:

<utils:persontextbox property="{binding      relativesource={relativesource ancestortype=itemscontrol},     path=datacontext.isineditmode}"/> 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -