c# - StringFormat of Datetime object in binding gives back 0 for hour and minute -


i create datetime object datetime.now , have property of class.

when bind grid view:

<gridviewcolumn header="date" width="120" displaymemberbinding="{binding transaction_date1, stringformat=hh:mm}" /> 

the result 00:00.

when debug code see hour, minute etc. properties of datetime object contain non-zero values. think stringformat in case gets hour , minute date object within datetime object has correct dates has 12:00:00 hour.

is there way go past , display right hour , minute in window?

thank in advance!

change this:

<gridviewcolumn header="date" width="120" displaymemberbinding="{binding transaction_date1, stringformat='{}{0:hh:mm}'}" /> 

if want use stringformat custom formatting, have use method provide param index in format string. equivalent to:

string.format("{0:hh:mm}", transaction_date1); 

the 2 curly braces @ start {} instruction xaml parser ignore further curly braces found in string. use date value multiple times in 1 binding statement:

displaymemberbinding="{binding transaction_date1, stringformat=`{} date-time {0:dd/mm/yy} @ approx. {0:hh} hours , {0:mm} minutes`}" 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -