silverlight - Bind combobox to collection in viewmodel -


i have combo box inside datagrid. datagrid bound item source. want fill combo box collection apart parent collection not working.

<data:datagrid x:name="dgtransferstockroomgldetails" autogeneratecolumns="false" columnheaderstyle="{staticresource datagridcolumnheaderstyle}"                                verticalscrollbarvisibility="visible" itemssource="{binding stockroomtransferdetails, mode=twoway}"                                canuserresizecolumns="false" verticalalignment="top" rowbackground="white" alternatingrowbackground="white" gridlinesvisibility="all" height="400">                     <data:datagrid.columns>                         <data:datagridtemplatecolumn header="from stockroom" width="200" canuserreorder="true" canusersort="true" isreadonly="false">                             <data:datagridtemplatecolumn.headerstyle>                                 <style targettype="prim:datagridcolumnheader">                                     <setter property="horizontalcontentalignment" value="center"/>                                     <setter property="fontweight" value="bold"/>                                 </style>                             </data:datagridtemplatecolumn.headerstyle>                             <data:datagridtemplatecolumn.celltemplate>                                 <datatemplate>                                 <!--<textbox text="{binding from_stkrm_id}" width="200" height="30" />-->                                 <combobox width="200" height="30" itemssource="{binding wiingsstkrmlist, mode=twoway, updatesourcetrigger=propertychanged}" displaymemberpath="name" />                                 </datatemplate>                              </data:datagridtemplatecolumn.celltemplate>                         </data:datagridtemplatecolumn>  </data:datagrid.columns>                 </data:datagrid> 

here view model

private observablecollection<buyerwebservice.stockroom> wiingsstkrmlist;         public observablecollection<buyerwebservice.stockroom> wiingsstkrmlist         {                          {                  return wiingsstkrmlist;              }             set              {                  wiingsstkrmlist = value;                 sendchangednotification("wiingsstkrmlist");             }         }          private observablecollection<buyerwebservice.stockroomtransfer> stockroomtransferdetails;         public observablecollection<buyerwebservice.stockroomtransfer> stockroomtransferdetails         {                         {                 return stockroomtransferdetails;             }             set             {                 stockroomtransferdetails = value;                 sendchangednotification("stockroomtransferdetails");             }         } 

i checked output window, says 'wiingsstkrmlist' property not found on 'buyerportal.buyerwebservice.stockroomtransfer'

stockroomtransfer used bind datagrid. combo trying find wiingsstkrmlist in parent item source.

how bind different collection?

you need specify relative source bound property can found, pointing @ parent element bound view model. this:

itemssource="{binding stockroomtransferdetails, relativesource={relativesource ancestortype=grid}}" 

change ancestortype=grid has datacontext of viewmodel ... outside of datagrid basically.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -