1

I found some usefull question but they didn't helped me. I'm developing Windows Phone 8 app and I want to show only dd.MM on TextBlock (DateTime binded) if culture is Turkish. If culture is en than display MM.dd

 Text="{Binding MyProperty.CreateDate, StringFormat=\{0:dd.MM\}}" 

Above code runs true in Turkish culture. But in English it's meaningless. Actually problem is not with the English or turkish. I just want to show Day and Month formatted in current culture.

1 Answer 1

1

If you want to specify your own format, you can create different format strings in your localization resource files and bind to StringFormat

Text="{Binding MyProperty.CreateDate, StringFormat={StaticResource shorDateFormatString}}" 

Alternatively, set the date text in the codebehind, with some custom logic to see whether the month or the day comes first in the local convention

string shortDatePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern if(shortDatePattern.indexOf("dd") < shortDatePattern.indexOf("MM")) dateLabel.Text = MyProperty.CreateDate.toString("dd.MM") else dateLabel.Text = MyProperty.CreateDate.toString("dd.MM") 

As suggested in this response

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.