binding - C# WPF two different DataContext in One Control while using MVVM and the secound property is every time the same -


first code:

<listview itemssource="{binding datatransfermodel.output}" background="transparent" margin="0" verticalcontentalignment="top" alternationcount="2" name="lvoutput" scrollviewer.verticalscrollbarvisibility="auto" grid.row="2">     <listview.itemtemplate>         <datatemplate>             <stackpanel orientation="horizontal" margin="0,1">                 <usercontrols:outputtextbox text="{binding data, mode=oneway}"                                              isreadonly="true"                                              grid.row="2"                                              textwrapping="wrapwithoverflow"                                              selectedvalue="{binding path=datacontext.selectedoutput,                                                              mode=twoway,                                                              updatesourcetrigger=propertychanged,                                                              relativesource={relativesource findancestor, ancestortype={x:type grid}}                                                             }"                                              />             </stackpanel>         </datatemplate>     </listview.itemtemplate> </listview> 

and problem property data on outputtextbox control comes list, property selectedoutput should come main datacontext viewmodel. , property selectedoutput should same every entry in list. dosn't work. :(

does listview enclosed in tags , if yes grid has datacontext viewmodel? if yes should work.

do see binding errors in output window? maybe should try using snoop see real binding of selectedvalue.

edit: please try type other grid, maybe listview if has viewmodel datacontext.

<usercontrols:outputtextbox text="{binding data, mode=oneway}"                                          isreadonly="true"                                          grid.row="2"                                          textwrapping="wrapwithoverflow"                                          selectedvalue="{binding path=datacontext.selectedoutput,                                                          mode=twoway,                                                          updatesourcetrigger=propertychanged,                                                          relativesource={relativesource findancestor, ancestortype={x:type listview}}                                                         }"                                          /> 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -