10

I want to to show the duration in minutes on my control but I don't want it to show up as with decimal numbers (eg, 65 instead of 65.94503).

<TextBlock Text="{Binding Duration.TotalMinutes, StringFormat=\{0\} minutes}" /> 

How can I do it?

2 Answers 2

13

If you want an integer to display, I think that all you need to do is set the StringFormat property as follows:

<TextBlock Text="{Binding Duration.TotalMinutes, StringFormat=N0}"/> 
Sign up to request clarification or add additional context in comments.

1 Comment

+1, Additionally {Binding Duration.TotalMinutes, StringFormat='{0:N0} minutes'} works.
0

Do that in code instead of the markup. You can unit test that easily. Make TotalMinutes a string or int instead and format it in the ViewModel.

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.