Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to use short date format from control panel in WPF datagrid

$
0
0

I try to format data grid rows to the short date format defined in the control panel. I found a lot of articles in the web which used something like either

<DataGrid ItemsSource="{Binding YourItemsSource}" StringFormat= 'de-DE'>

or <DataGrid ItemsSource="{Binding YourItemsSource StringFormat= 'YYYY-MM-DD}">. Both work fine, but my problem is: the culture of the machine is set to german which would give the format dd.MM.JJJJ, but the Short Format of the control panel was modified to 'YYYY-MM-DD'. Furthermore, I always want to apply the date format from the control panel, regardless to what it was changed on any machine. I know that I can retrieve the actual  Short Date Format from the machine with CultureInfo.GetCultureInfo, but how can I apply this as parameter to my StringFormat? In XAML there is always text in the string format, and as far as I have read, value converters also take text and no parameters or variables?So, how can I apply the actual Short Date Format from the control panel to my DataGrid rows?     Hartmut


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>