jas*_*onk 4 c# data-binding wpf
我正在尝试在顶部实现一个带有文本框的进度条,同时显示进度%.但百分比是分数.是否可以通过绑定对数据集中返回的值进行舍入,还是必须通过后面的代码完成?
<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" />
Run Code Online (Sandbox Code Playgroud)
使用绑定的StringFormat属性,例如:
{Binding Path=ProgressIndex, Mode=OneWayToSource, StringFormat=2N}
Run Code Online (Sandbox Code Playgroud)