Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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?
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}"/>
Add a comment
{Binding Duration.TotalMinutes, StringFormat='{0:N0} minutes'}
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.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.