如何在 XAML 中格式化双精度值以在没有科学表示的情况下在末尾删除零?

as7*_*s74 3 c# wpf xaml listview string-formatting

我需要在 ListView 中显示双值,例如:0.00008。不幸的是,值经常被表示为指数/科学:1E-8。我不希望用户看到 1E-8 类型的值。我不知道也不想知道使用过的双精度数的小数点精度。我不能打双打。我可以使用 c# 解决这个问题:

string s = doubleValue.ToString("0.####################");  // gives what I need: 0,00008
Run Code Online (Sandbox Code Playgroud)

如何使用 xaml 进行完全相同的格式化?

<ListView.View>
  <GridView AllowsColumnReorder="False">
    <GridView.Columns>
     <GridViewColumn.CellTemplate>
        <DataTemplate>
            <Border>
                <Grid>
                    <TextBlock x:Name="textBlock1" Text="{Binding Path=Profit, StringFormat={{???}}" TextTrimming="CharacterEllipsis"  />
                </Grid>
            </Border>
        </DataTemplate>
    </GridViewColumn.CellTemplate>
  </GridView.Columns>
 </GridView>
</ListView.View>
Run Code Online (Sandbox Code Playgroud)

或者如何使用 c# 在后面的代码中将这种格式分配给 textBlock1 ?

Viv*_*Viv 6

<TextBlock x:Name="textBlock1"
            Text="{Binding Path=Profit,
                          StringFormat={}{0:0.####################}}"
            TextTrimming="CharacterEllipsis" />
Run Code Online (Sandbox Code Playgroud)