c# - How to bind a control of a row detail to the property of the view model -
during development works, want create datagrid row detail information. each row compose class info such as, class name , total number of students. when user click 1 row display pupil info of selected class row detail.
the row detail command create datagrid, each row of grid pupil information.
the pupil name edit autocompletebox control. itemsource of should bound property studentnames of viewmodel , not property of classinformation. classinforamtion property of viewmodel. result not works. during editing, studentnames not binded currectly.
<usercontrol ...> <grid x:name="layoutroot" ...> <sdk:datagrid autogeneratecolumns="false" itemssource="{binding classinformation}" rowdetailsvisibilitymode="visiblewhenselected" selecteditem="{binding selectedclass, mode=twoway}" x:name="datagrid"> <sdk:datagrid.columns> <sdk:datagridtextcolumn header="name" binding="{binding name}"/> <sdk:datagridtextcolumn header="total student" binding="{binding totalstudent}" isreadonly="true"/> </sdk:datagrid.columns> <sdk:datagrid.rowdetailstemplate> <datatemplate> <grid> <grid.columndefinitions> <columndefinition/> <columndefinition width="auto"/> </grid.columndefinitions> <sdk:datagrid autogeneratecolumns="false" grid.column="0" itemssource="{binding studentinformation}"> <sdk:datagrid.columns> <sdk:datagridtemplatecolumn header="student name"> <sdk:datagridtemplatecolumn.celltemplate> <datatemplate> <textblock x:name="studentname" text="{binding ssdtestscript.name}"/> </datatemplate> </sdk:datagridtemplatecolumn.celltemplate> <sdk:datagridtemplatecolumn.celleditingtemplate> <datatemplate> <sdk:autocompletebox itemssource="{binding path=datacontext.studentnames, elementname="layoutroot"}" itemfilter="{binding elementname=studentname, path=text}"/> </datatemplate> </sdk:datagridtemplatecolumn.celleditingtemplate> </sdk:datagridtemplatecolumn> </sdk:datagrid.columns> </sdk:datagrid> </grid> </datatemplate> </sdk:datagrid.rowdetailstemplate> </sdk:datagrid> </grid> </usercontrol>
i have tried or binding expressions too.
itemssource="{binding path=scriptnames}" datacontext="{binding}" itemssource="{binding path=scriptnames, relativesource={relativesource mode=findancestor, ancestortype=grid}}" itemssource="{binding path=scriptnames, relativesource={relativesource mode=findancestor, ancestortype=usercontrol}}"
by way, how specify ancestorlevel in silverlight 5? have seek expression, throw exception when navigate page. depend on logic tree of xaml?
itemssource="{binding path=scriptnames, relativesource={relativesource mode=findancestor, ancestorlevel=2}}"
any suggestions appreciated! in advance.
c# wpf xaml silverlight
No comments:
Post a Comment