您可以像这样更改 ProgressBar 颜色:
percentprogress.Foreground = new SolidColorBrush(Color.FromArgb(255, 24, 50, 60));
percentprogress.Foreground = new SolidColorBrush(Colors.Orange);
每次用户打开应用程序时更改代码 - 在 App.xaml.cs 中,在 Application_Launching 和 Application_Activated 方法中保存一些应更改颜色的静态标志
public static bool ChangeColor;
private void Application_Launching(object sender, LaunchingEventArgs e)
{
ChangeColor = true;
}
private void Application_Activated(object sender, ActivatedEventArgs e)
{
ChangeColor = true;
}
然后在您的页面中更改它,如下所示:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (App.ChangeColor)
{
Random m = new Random();
percentprogress.Foreground = new SolidColorBrush(
Color.FromArgb(255, (byte)m.Next(0, 255), (byte)m.Next(0, 255), (byte)m.Next(0, 255)));
App.ChangeColor = false;
}
}