I'm using WPF to display Products on my DataGrid, for database I am using MySql database,
decimals in mysql are stored as 100.30, 100.10, 90.40, as you can see mysql is using dot(".") as separator between decimals, and to show it on my screen as comma separated, I used next thing:
<DataGridTextColumn Binding="{Binding Price, StringFormat='{}{0:C}',ConverterCulture=EN}" Header="PRICE" FontSize="15" FontFamily="Verdana" Width="10*" />
I set culture info to my DataGridTextColum where I am displaying my price, but in case someone someday would like to change that culture info how could I acces this DataGridTextColumn and change culture info for that column "Price" .. ?
Thanks guys, Cheers
If you give the column an x:Name
(like "col1") in your XAML markup you should be able to access it and its properties programmatically like this:
Binding b = col1.Binding as Binding;
string format = b.StringFormat;
var c = b.ConverterCulture;
Note that you won't be able to change any property of the binding after it has been used though so if you need to change the culture or the StringFormat
you must either do this in the constructor before the binding has been resolved or by simply editing the XAML markup. It can't be done programmatically after the binding has been resolved.