我想是这样的:

String.Format("Value: {0:%%}.", 0.8526)

在哪里%%是格式提供或任何我期待的。 应导致:Value: %85.26.

基本上,我需要它为WPF结合,但首先让我们解决了一般格式问题:

<TextBlock Text="{Binding Percent, StringFormat=%%}" />
有帮助吗?

解决方案

使用 P格式字符串。这将通过培养而异:

String.Format("Value: {0:P2}.", 0.8526) // formats as 85.26 % (varies by culture)
scroll top