Silverlight绑定使用字符串格式为0显示空白



是否可以使用StringFormat属性以某种方式使0值显示为空,或者可以通过编写自定义转换器来实现?

该值为双重类型。

输入为0,输出应为"。但当输入不是0时,输出应该等于输入。

编辑:

我试过了:

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" />

为了总结注释,您可以将StringFormat指定为{0:#},它将用空字符串替换0:

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

自定义数字格式字符串

最新更新