c# - Reusing data template for multiple types? -


i have following datatemplate displaying full name of user instance:

<datatemplate x:key="namecelltemplate">     <label horizontalalignment="stretch" height="25">         <label.content>             <multibinding                  converter="{staticresource fullnameconverter}"                 converterparameter="{x:static conv:nameformat.firstthenlast}" >                  <!-- requires binding object of type 'user' -->                 <binding path="firstname" />                 <binding path="lastname" />             </multibinding>         </label.content>     </label> </datatemplate> 

i use customize template column, so:

<datagridtemplatecolumn      celltemplate="{staticresource namecelltemplate}" /> 

this column belongs data grid full of user instances, re-use data template column in different data grid. second data grid binds different type, instead keeps user property, i'd like this:

<datagridtemplatecolumn      binding="{binding path=user}"      celltemplate="{staticresource namecelltemplate}" /> 

however, binding attribute isn't permitted template column.

how can specify binding path column template, or modify data template, such data template can reused either data grid?

in case datacontexts of datagrid row different can apply template this:

<datagridtemplatecolumn>     <datagridtemplatecolumn.celltemplate>         <datatemplate>             <contentcontrol content="{binding user}"                              contenttemplate="{staticresource namecelltemplate}"/>         </datatemplate>     </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -