Text formatting
(Created page with "As you bind data to your model you may want to influence how that data is presented. Regretfully we have not found a common way to do this across all our supported platforms...")
 
No edit summary
Line 6: Line 6:


=== WPF ===
=== WPF ===
For WPF use tagged value '''StringFormat'''. This value is sent into the binding and adheres to the common texttransforms pattern defined here [https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings for numbers] [https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings for DateTimes] and [https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-timespan-format-strings for TimeSpan]
For WPF use tagged value '''StringFormat'''. This value is sent into the binding and adheres to the common text transforms pattern defined here [https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings for numbers] [https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings for DateTimes] and [https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-timespan-format-strings for TimeSpan]


WPF is very good at this and allows for the original value to be presented by the format even when the value is two way bound and editable.
WPF is very good at this and allows for the original value to be presented by the format even when the value is two way bound and editable.
Line 12: Line 12:
=== AngularJS ===
=== AngularJS ===
For Angular use tagged value '''StringFormatAngular'''. This value is appended behind the binding as a Angular Filter. Angular has basic capabilities and is not able to handle this kind of formatting for two-way-databind - so it works best for read only values.
For Angular use tagged value '''StringFormatAngular'''. This value is appended behind the binding as a Angular Filter. Angular has basic capabilities and is not able to handle this kind of formatting for two-way-databind - so it works best for read only values.
For Angular you can transform dates [https://angular.io/api/common/DatePipe according to this guide]


=== MVC ===
=== MVC ===
In MVC - use '''StringFormatRazor''' - we can transform in Razor code and thus have many of the same possibilies as in WPF for read-values. Write values are harder - so this works best for one way bind.
In MVC - use '''StringFormatRazor''' - we can transform in Razor code and thus have many of the same possibilities as in WPF for read-values. Write values are harder - so this works best for one way bind.

Revision as of 20:54, 11 March 2020

As you bind data to your model you may want to influence how that data is presented.

Regretfully we have not found a common way to do this across all our supported platforms - so we have implemented parallel strategies in order to get the job done.

Om a ViewModel column you set Tagged Values in order to convey your wish via the model.

WPF

For WPF use tagged value StringFormat. This value is sent into the binding and adheres to the common text transforms pattern defined here for numbers for DateTimes and for TimeSpan

WPF is very good at this and allows for the original value to be presented by the format even when the value is two way bound and editable.

AngularJS

For Angular use tagged value StringFormatAngular. This value is appended behind the binding as a Angular Filter. Angular has basic capabilities and is not able to handle this kind of formatting for two-way-databind - so it works best for read only values.

For Angular you can transform dates according to this guide

MVC

In MVC - use StringFormatRazor - we can transform in Razor code and thus have many of the same possibilities as in WPF for read-values. Write values are harder - so this works best for one way bind.

This page was edited 53 days ago on 03/26/2024. What links here