EDIT: I don't want it to update, change or go away. I ONLY want the taskbar to be at 40% to start the program, stay that way till it closes.
I spent a lot of hours and tried many examples...but no luck.
To keep it simple, how do you show 40% done in Error color?
This code runs but does nothing on the screen, no errors, just runs right by:
public TaskbarItemInfo taskBar = new TaskbarItemInfo();
then in a method:
taskBar.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Error;
taskBar.ProgressValue = 0.40;
If you breakpoint on the next line and look, it has set the values, they just don't do anything on the screen...
Here's a short example that you should be able to use to tailor to your needs:
System.Windows.Window w = new System.Windows.Window();
w.TaskbarItemInfo = new System.Windows.Shell.TaskbarItemInfo() { ProgressState = System.Windows.Shell.TaskbarItemProgressState.Normal };
w.Loaded += delegate {
Action<Object> callUpdateProgress = (o) => {
w.TaskbarItemInfo.ProgressValue = (double) o;
};
Thread t = new Thread(() => {
for (int i = 1; i <= 10; i++) {
w.Dispatcher.BeginInvoke(callUpdateProgress, 1.0 * i / 10);
Thread.Sleep(1000);
}
});
t.Start();
};
System.Windows.Application app = new System.Windows.Application();
app.Run(w);
To make the above work you need to have using System.Threading;
at top and also add references of: PresentationCore
, PresentationFramework
, SystemXaml
, WindowsBase
.