Reputation: 2063
I found something like this: How to set WPF string format as percent wihout multiplying by 100?
I just want to have a '%' sign suffix after my number. my code looks like this
<Label Content="{Binding Path=ReportGridViewModel.FillingDegree, StringFormat=P}" />
I already tried this one too
<Label Content="{Binding ReportGridViewModel.Cgi, StringFormat={}{0}%}" />
in both cases I don't see any changes like I don't have any stringformat.
Upvotes: 4
Views: 1288
Reputation: 19416
The StringFormat
property of a Binding
is only applied when the target property is of type String
. In a Label
, the target property Content
, is of type Object
, so StringFormat
is not respected.
To get this to work in a label, use ContentStringFormat
. If you were to use a TextBlock
, you could use the StringFormat
provided by Binding
.
Upvotes: 3
Reputation: 139758
In the case of Label
you need to use the ContentStringFormat property
<Label Content="{Binding Path=ReportGridViewModel.FillingDegree}"
ContentStringFormat="P" />
Upvotes: 3