【问题标题】:WPF ProgressBar going from 100% to 1%WPF ProgressBar 从 100% 变为 1%
【发布时间】:2014-06-13 09:27:45
【问题描述】:

我有一个 WPF 进度条,我想报告将流的字节传输到数据库的进度。但是,我将剩下的字节除以总数并乘以 100:

    int percentage = (int) (streamlength / BytesLeft) * 100;

所以基本上它从 100 变为 1,有没有办法可以在进度条上表示它?

  <ProgressBar HorizontalAlignment="Left" Height="21" Margin="723,204.2,0,0" VerticalAlignment="Top" Width="411" Minimum="0" Maximum="100" Name="pbStatus" Value="{Binding BytesToDatabase, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" />

如果没有,我会改变计算。

【问题讨论】:

  • 它从 100 变为 1 ???
  • @Sayse:我猜是错字,否则根本无法编译。
  • 对不起,这是一个错字,这是我提出的一个愚蠢的问题,最好删除

标签: c# wpf progress-bar


【解决方案1】:

您应该切换两者(streamlengthBytesLeft):

int percentage = (int) (BytesLeft / streamlength) * 100;

【讨论】:

    猜你喜欢
    • 2015-05-19
    • 2014-05-09
    • 1970-01-01
    • 2011-03-05
    • 1970-01-01
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    • 2015-12-05
    相关资源
    最近更新 更多