I often use text fields in my wpf projects that are bound to datetime properties. I want to format dates in German dd.MM.yyyy format. I am currently doing this with a converter recorder, which I can provide the desired date format.
For example, for example:
<TextBox Name="Date" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type prj:MyBar}}, Path=Date, Converter={StaticResource dateConverter}, ConverterParameter=dd.MM.yyyy}" />
The only thing the converter does is call the ToString(string formatString) DateTime method.
Is there a smarter way to format dates with data binding. It would be best if you do not need to write a C # code. Perhaps there is some existing class in microsoft-libs that could do such a date conversion for data binding, but I haven't found it yet.
It would be great if there were any tips,
Hi, Martin
source share