0

Is it possible to somehow make 0 values appear blank using the StringFormat property, or is it acheivable by writing a custom converter?

The value is of double type.

Input is 0, output should be "". But when input is other than 0 then output should equal input.

EDIT:

I tried :

sdk:DataGridTextColumn x:Name="colBidQty" Header="Bid Qty" Binding="{Binding BidPrice.Quantity, Mode=TwoWay, StringFormat="{}{0:#}"}" Foreground="Black" ToolTipService.ToolTip="{Binding Path=BidPrice.ToolTip}" ToolTipService.Placement="Right" />
9
  • can you give an example? what is input and what you want as an output. Commented Jul 30, 2013 at 11:24
  • for eg- double d = 1010101010; output=1 1 1 1 1 double d=111111 output=111111...is this what you want..? Commented Jul 30, 2013 at 11:34
  • No, not replace all zeros, the value will be just one 0, then replace with "", else do not. Commented Jul 30, 2013 at 11:35
  • 1
    @MuhammadA, did you try {}{0:#}? Commented Jul 30, 2013 at 11:39
  • 1
    @MuhammadA, it seems to be different in Silverlight. Give this a try: Binding="{Binding BidPrice.Quantity, Mode=TwoWay, StringFormat='{}{0:#}'}" Commented Jul 30, 2013 at 11:58

1 Answer 1

1

To sum up comments, you can specify StringFormat as {0:#} which will replace 0 with empty string:

Binding="{Binding BidPrice.Quantity, Mode=TwoWay, StringFormat='{}{0:#}'}"

Custom Numeric Format Strings

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.