views:

39

answers:

2

Hello, I am playing around with C# and WPF. I am coming from the realm of microcontrollers and was wondering for the correct way to do things.

My question is this, say for my horses I wanted to build an automated water dispenser as a school project for my kids using software. In the water control panel, the user would be able to see the tank level.

TankLevelControl has a dependancy property [ TankLevelFillProperty ] (I hope I am using that right)

Would it be best (in terms of graphical flexibility and lower skill level) to make a CustomControl or reimplement a progress bar? What I had in mind it looking like was something along these lines: link text

I am just mediocre at programming (but learning all the time :) )

Thanks for any help

+2  A: 

Well either approach would work.

Re-purposing the progress bar would get you a lot of code "for free". You'd just have to update the "progress" variable and the display would update accordingly. You'd have to style the control yourself though.

Writing your own Custom Control would involve more coding, but you'd probably learn more.

ChrisF
Thanks, I will have to try the longer way in the name of learning :)
Dan C
A: 

The "WPF" way to do this would be to re-template the ProgressBar control, in my opinion.

You shouldn't need a TankLevelControl, as it's just a different graphical representation of a progress bar. Simply bind your tank level to the Value of the progress bar (and obviously, set the MinValue to 0 and the MaxValue to the capacity of the tank (again, probably bind that from your data model?) then go nuts with XAML templates.

Giraffe