I have searched in Google using a progress bar in WPF that will be manually incremented and decremented using a plus and minus button. But, to no avail haven't found one that is similar to what I want though.
How do I implement a WPF progress bar that will be manually incremented or decremented (using buttons) in an MVVM way. The screen capture below shows the mock-up UI design.
The image show that when the user click the plus button, the progress bar will be incremented by 10 minutes. On the other hand, the minus button when clicked, decrements the progress bar by 10 minutes.
I'm just starting to learn WPF and MVVM. Any help is greatly appreciated.
I think you should solve that by use custom Slider control of WPF instead Progress bar. This link can help you : http://www.codescratcher.com/wpf/custom-slider-control-in-wpf/
I created a simple example which uses WPF and MVVM to show how one model can be displayed with different views. Here in xaml I placed on a form
Slider
andProgressBar
- they are Views for our ViewModel. The properties we need (Minimum, Maximum, Value) are binded to the ViewModel's properties. "Plus" and "Minus" buttons' properties "Command" are also binded to the corresponding props in the ViewModel(IncreaseCommand, DecreaseCommand).For implementing the commands functionality in ViewModel you will need to create an implementation of
ICommand
interface:And here's the ViewModel class, it implements
INotifyPropertyChanged
interface to keep views updated.And the last thing to get it all working is to create new ViewModel and set
DataContext
of a window to this model: