StringFormat似乎没有反应
问题描述:
我在我的xaml中有以下绑定,我可以看到显示的double值,但StringFormat
完全被忽略。StringFormat似乎没有反应
<Label Content="{Binding ByteCount, StringFormat=n}"/>
ByteCount
属性是double类型的。我甚至改变它甚至串起来,它仍然不起作用。
请问可能是什么原因?
更新:
public double ByteCount
{
get
{
return CloneHelper.GetSize(this);
}
}
public static class CloneHelper
{
public static double GetSize(BookSetViewModel book)
{
.....
return total;
}
}
答
不知道是什么原因,也许是因为目标类型(标签是对象),但它适用于TextBlock:
<TextBlock Text="{Binding ByteCount, StringFormat=n}"/>
其中是绑定? –
也许你可以在你的问题中包含实际的绑定? (顺便说一句:一个ByteCount属性表示为double !?) –
如果'ByteCount'是一个'int',则可能缺少一个转换器。 –