sprocket12
sprocket12

Reputation: 5488

Silverlight binding using stringformat to display blank for 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" />

Upvotes: 0

Views: 395

Answers (1)

dkozl
dkozl

Reputation: 33364

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

Upvotes: 1

Related Questions