【发布时间】:2019-07-04 22:18:35
【问题描述】:
我有一个进度条,它以绿色开始,然后改变行为并变为红色和不确定,最后在最后一步返回确定。
在第二步中红色是正确的,但在最后一步中,前景色是错误的,它是棕色而不是红色。
xaml 文件中的进度条:
<Grid Margin="10,0" Height="58" VerticalAlignment="Bottom">
<ProgressBar x:Name="progress_bar" Height="20" VerticalAlignment="Bottom" Margin="0,0,0,38" />
<TextBlock x:Name="progress_bar_text" Margin="300,2,300,40" HorizontalAlignment="Center" >0% - Waiting to start...</TextBlock>
</Grid>
那么当按下中止按钮时:
private void Button_abort_Click(object sender, RoutedEventArgs e)
{
progress_bar.IsIndeterminate = true;
progress_bar.Foreground = Brushes.Red;
}
最后,当任务终止时,任务栏行为返回确定。
progress_bar.IsIndeterminate = false;
progress_bar.Foreground = Brushes.Red;
为什么进度条是棕色而不是红色?
【问题讨论】:
-
可能是因为您使用的默认 Windows 7 主题会洗掉颜色?
-
@DenisSchaf 是的,我使用的是 Windows 7
-
我的系统上的进度条颜色是红色的。可能@DenisSchaf 是对的。我使用的是 Windows 10
-
“前景色错误” - 透明和灰色背景改变了颜色,但它是红色的。不确定如何轻松处理
ProgressBar,终止是否需要很长时间?我的意思是,您真的需要查看中断进度吗?您可以停止进度,但在终止之前阻止开始。