robert-j-engdahl / ngettext-wpf

Proper internationalization support for WPF (via NGettext)
GNU Lesser General Public License v3.0
10 stars 12 forks source link

GettextFormatConverter does not support DisplayFormat #35

Open Jogge opened 5 years ago

Jogge commented 5 years ago

I'm trying to bind to this property with the GettextFormatConverter:

[DisplayFormat(DataFormatString = "d")]
public DateTime Date { get; set; }
<TextBlock Text="{Binding Date, Mode=OneWay, Converter={wpf:GettextFormatConverter Date: {0}}}" />

Expected result: Date: 11-03-2019

Result: Date: 11-03-2019 00:00:00

robert-j-engdahl commented 5 years ago

Setting the StringFormat twice, once in the attribute and again in the GettextFormatConverter is ambiguous.

On the other hand, the attribute approach enables DRY, so no format specification should mean fall back to the DisplayAttribute, but a given format specification would override that.

<TextBlock Text="{Binding Date, Converter={wpf:GettextFormatConverter Date: {0}}}" />

formats Date according to the DisplayFormat attribute and

<TextBlock Text="{Binding Date, Converter={wpf:GettextFormatConverter Date: {0:g}}}" />

formats the Date with the given g