我正在尝试实现一个进度条,顶部有一个文本框,也显示进度%。然而,该百分比是小数。是否可以通过绑定对数据集中返回的值进行舍入,还是必须通过后面的代码来完成?
<ProgressBar Grid.Row="2" Grid.ColumnSpan="2" Height="25" HorizontalAlignment="Stretch" Margin="5,5,5,2" Name="pbProgressIndex" VerticalAlignment="Top" Width="Auto" Value="{Binding Path=ProgressIndex, Mode=OneWayToSource}" />
<TextBlock Grid.Row="2" Grid.ColumnSpan="2" Height="25" Name="txtProgressIndex" Text="{Binding Path=ProgressIndex, Mode=OneWayToSource}" Width="Auto" Foreground="Black" FontWeight="Bold" FontSize="14" FontFamily="Verdana" Padding="5" Margin="5,5,5,5" TextAlignment="Center" />
Use the 字符串格式绑定的属性,例如:
{Binding Path=ProgressIndex, Mode=OneWayToSource, StringFormat=N2}
The N2
还可以通过以下方式指定格式:
{}{0:N2}}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)