c# - How to specify DataTemplate for object -
i have following code:
public class fieldviewerselector : imultivalueconverter { public datatemplate percenttemplate { get; set; } public datatemplate filesizetemplate { get; set; } #region ivalueconverter members //.... #endregion } <commonconverters:fieldvalueconverter x:key="fieldvalueconverter" /> <commonconverters:percentvalueconverter x:key="percentvalueconverter" /> <commonconverters:filesizevalueconverter x:key="filesizevalueconverter" /> <commonconverters:fieldviewerselector x:key="fieldviewerselector"> <commonconverters:fieldviewerselector.filesizetemplate> <datatemplate> <!--datatemplate same--> </datatemplate> </commonconverters:fieldviewerselector.filesizetemplate> <commonconverters:percentvalueconverter> <datatemplate> <!--datatemplate same--> </datatemplate> </commonconverters:percentvalueconverter> </commonconverters:fieldviewerselector> <datatemplate x:key="template"> <grid> <grid.columndefinitions> <columndefinition width="250" /> <columndefinition width="*" /> </grid.columndefinitions> <textblock style="{staticresource leftcolumn}" text="{binding path=displayname, mode=oneway}"/> <border background="{staticresource lightgray}" grid.column="1"> <textbox style="{staticresource readonlytextbox}"> <textbox.text> <binding <!--only following line different depends on property--> converter="{staticresource percentvalueconverter}" <!--converter="{staticresource fieldvalueconverter}"--> mode="oneway" path="datacontext.item" relativesource="{relativesource ancestortype=window}"/> </textbox.text> </textbox> </border> </grid> </datatemplate>
so don't know how specify particaular datatemplate correct converter via binding or way. have in order not repeat myself =)
Comments
Post a Comment