5

How can I modify certain WPF controls (i.e. combobox, textbox, etc) to have a progressbar in the background of the control (which I can enable and disable on demand). I don't need it to actually show an accurate progress, rather I just need an indication that this control is waiting for something to finish. A spinning icon inside the control would be OK too.

I have seem some answers that deal with having one control on top of another and setting transparency, etc, but I would greatly prefer to find a better solution.

Thanks!

user981225
  • 8,762
  • 6
  • 32
  • 41

1 Answers1

5

You can put anything anywhere, you just need to modify the respective Template, which may not be trivial, you could start by copying the existing ones.

To enable and disable easily you maybe should subclass the control you target so you can have a dedicated dependency property for that which can be bound to the Visibility of the ProgressBar in the template (perhaps with a BooleanToVisibilityConverter).

Community
  • 1
  • 1
H.B.
  • 166,899
  • 29
  • 327
  • 400
  • I concur with this answer. You can do a lot of custom stuff in WPF , so this could also be achieved with a user Control (or Custom Control, if needed). However, providing a new control template and a sub-classed control would also be my recommendation. – Adam Dec 02 '11 at 17:29
  • Thank you for the advice. In order to modify the control template, do I need to know what the existing one is? For example, I am using DevExpress's ComboBoxEdit, which might have a different Template than what you linked to. – user981225 Dec 02 '11 at 17:35
  • @user981225: You do not need to know the details, but you need to know the essential parts, usually those are noted as [attributes on the class](http://msdn.microsoft.com/en-us/library/system.windows.templatepartattribute.aspx). These controls need to appear in the template and should have the respective part-name. – H.B. Dec 02 '11 at 18:15