Xaml 作为标签分隔符的空间
我有一个标签,我使用绑定和格式化字符串:Xaml 作为标签分隔符的空间,xaml,xamarin.forms,custom-formatting,Xaml,Xamarin.forms,Custom Formatting,我有一个标签,我使用绑定和格式化字符串: <Label Text="{Binding buying_price , StringFormat='{0} EUR'}"> 标签的文本在我的ViewModel中绑定到一个双精度,我在标签上得到的是这样的:10000欧元,我想要得到的是10000欧元,例如12501 005欧元(没有尾随的.00)。 我试过StringFormat='{0:C2}EUR'和StringFormat='{0:N}EUR'和StringF
<Label Text="{Binding buying_price , StringFormat='{0} EUR'}">
标签的文本在我的ViewModel中绑定到一个双精度,我在标签上得到的是这样的:10000欧元
,我想要得到的是10000欧元
,例如12501 005欧元
(没有尾随的.00)。
我试过
StringFormat='{0:C2}EUR'
和StringFormat='{0:N}EUR'
和StringFormat='{0:N}EUR'
但没有一个给了我一个好的结果。试着使用StringFormat='{0:“
根据您的文化背景,如果您得到的结果是10000欧元
,而不是10000欧元
,您可能需要在代码隐藏中更改它,在前者中,是一个千位分隔符,而不是逗号
您可能需要查看完整的文档以获取可用信息
有助于区域性的相关问题:尝试使用
StringFormat='{}{0:#,##,#}
根据您的区域性,如果您得到的结果是10000欧元
,而不是10000欧元
,则可能需要在代码后面的代码中更改它,在前者中,是一个千位分隔符,而不是逗号
您可能需要查看完整的文档以获取可用信息
有助于区域性的相关问题:我没有让它在xaml中工作,而当我在代码隐藏中使用转换和使用字符串格式时,它可以作为例外:
<ContentPage.Resources>
<ResourceDictionary>
<local:thousandsSeparatorConverter x:Key="thousandsSeparator"/>
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout>
<!-- Place new controls here -->
<Label Text="{Binding date, Converter={StaticResource thousandsSeparator}}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"/>
</StackLayout>
我没有让它在xaml中工作,但当我在代码隐藏中使用convert和use string格式时,它的工作方式例外:
<ContentPage.Resources>
<ResourceDictionary>
<local:thousandsSeparatorConverter x:Key="thousandsSeparator"/>
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout>
<!-- Place new controls here -->
<Label Text="{Binding date, Converter={StaticResource thousandsSeparator}}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"/>
</StackLayout>
你需要做一个蒙面条目你需要做一个蒙面条目