简体   繁体   中英

Implementing a bar in a WPF program

I'm looking to make a WPF application that uses an illuminated bar as a "progress bar." Not in the traditional sense such as a program loading, but to display to the user how far he has progressed in a certain objective/task. Below is an example of the bar I am trying to describe.

Progress Bar

I would like to make a path using multiple bars connected to each other but have no idea how to go about putting them in the program. Thanks for your answers in advance!

As @ORMapper correctly pointed out, the ProgressBar control is the correct way to go, using a control template to make it look however you'd like.

Regarding your second question: if you want the value of one ProgressBar to be dependent on a value of another ProgressBar, you should modify the Maximum property to correctly show the intended value.

For example, if you have one Main progress bar, which should reach 100% only after 2 other tasks have been completed - give it a Maximum value of 200, then set its value by using a calculation such as: MainProgressBar.Value = firstTaskValue + secondTaskValue .
It will only reach 100% after the 2 tasks have been completed...
You can play with this however you want, for instance if one task is more important then another: MainProgressBar.Value = firstTaskValue + 2 * secondTaskValue .

Anyways, this is logic you'll have to implement by yourself...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM