I made a similar question months ago
In this case I have a textblock like this
<TextBlock FontSize="28" Text="{Binding DataPoint.Y, StringFormat=\{0:0\\%\}}" Foreground="Black">
As you can see, my StringFormat puts a '%' sign after the number, if my data is 0.0 (I fill the component in code behind, my variable is a double) I get "0%"
But now I want to get "" if my text is 0.0
So far I have this:
Text="{Binding DataPoint.Y, StringFormat=\{0:#.#\\%\}}"
But this retrieves "%", how can I get ""?
None of these worked for simple positive integers. I had a field which would always default to 0. To hide it, but not add any decimals places, I use:
Text="{Binding BuyerNumber, StringFormat=0;;#}"
Hope this helps someone out who is looking for integers only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With