How to set foreground on part of multi binding when concatenating two properties in WPF XAML? -


i displaying 2 property values using multi-binding in wpf xaml. want set first/second value different color.

    <datagridtemplatecolumn header="concatcol"                                             width="60">                         <datagridtemplatecolumn.celltemplate>                             <datatemplate>                                 <textblock textalignment="right">                                     <textblock.style>                                         <style targettype="textblock">                                             <setter property="text">                                                 <setter.value>                                                     <multibinding stringformat="{} {0:c1} / {1:c1}">                                                         <binding path="firstprop" />                                                         <binding path="secondprop" />                                                     </multibinding>                                                 </setter.value>                                             </setter>                                         </style>                                     </textblock.style>                                 </textblock>                             </datatemplate>                         </datagridtemplatecolumn.celltemplate>                     </datagridtemplatecolumn> 

so can see displaying 2 property values in single cell separating them "/". specifying string format each of property.

now question how can display value before "/" in green color , latter in red color?

you use textblock multiple runs:

<textblock textalignment="right">    <run text="{binding firstprop}" foreground="green"/> / <run text="{binding secondprop}" foreground="red"/> </textblock> 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -