我正在尝试以编程方式在wpf中创建进度条。到目前为止,这是我的代码
infoWindow = new Window();
infoWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
infoWindow.SizeToContent = SizeToContent.WidthAndHeight;
infoWindow.Title = "Please wait...";
StackPanel stackPanel = new StackPanel();
stackPanel.Orientation = Orientation.Vertical;
ProgressBar progressBar = new ProgressBar();
progressBar.IsIndeterminate = true;
progressBar.Margin = new Thickness(10,0,10,10);
progressBar.Visibility = Visibility.Visible;
progressBar.Height = 25;
progressBar.FlowDirection = FlowDirection.LeftToRight;
progressBar.Foreground = System.Windows.Media.Brushes.Green;
progressBar.Background = System.Windows.Media.Brushes.Red;
stackPanel.Children.Add(progressBar);
infoWindow.Content = stackPanel;
infoWindow.Show();
我从中得到的是一个红色的进度条。但是没有动画像我们复制文件时那样发生。 (我不想显示任何进展,只是以圆形方式在整个条带上移动的光)。 我在这里缺少什么想法?