This is a migrated thread and some comments may be shown as answers.

Programmatically change Progress Bar color without themes

4 Answers 264 Views
ProgressBar
This is a migrated thread and some comments may be shown as answers.
Mike Baldini
Top achievements
Rank 2
Mike Baldini asked on 02 Mar 2010, 10:47 PM
What we are trying to do is provide our users with a progress bar that changes from green to yellow, and yellow to red at predetermined values of the 'Value1' property. I know in another thread you mentioned that you would add a 'ProgressBarColor' property for the 'Value1' and 'Value2' properties, but is there any other way to do it outside of theming?  We would love to avoid having to create and switch between multiple themes.
Is there any way to programmatically access the FillPrimitive inside of the RadProgressBarElement?

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 05 Mar 2010, 04:01 PM
Hello Mike Baldini,

Thank you for the question.

In order to change the colors of RadProgressBar, you actually need the ProgressBarPrimitive instance:
ProgressBarPrimitive prim = (ProgressBarPrimitive)this.radProgressBar1.ProgressBarElement.Children[1];

However, it may be a bit difficult to control GradientPercentage and GradientPercentage2 properties dynamically. Therefore, you can insert a FillPrimitive with predefined colors and make the colors of the ProgressBarPrimitive transparent. In addition, when the progress is running, you should move the gray FillPrimitive of RadProgressBar to right. This will allow you to achieve the desired look. I am attaching a sample project which demonstrates the approach.

I hope this helps. If you have additional questions, feel free to contact me.

Best wishes,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Nazmi
Top achievements
Rank 1
answered on 24 Jun 2014, 09:05 PM
When I run the sample project, I am getting the error below: 

Unable to cast object of type 'Telerik.WinControls.UI.UpperProgressIndicatorElement' to type 'Telerik.WinControls.Primitives.ProgressBarPrimitive'.

Could you modify the sample project?

Thanks
0
Ralitsa
Telerik team
answered on 26 Jun 2014, 09:44 AM
Hello Nazmi,

Thank you for contacting us.

You can download the modified sample project. 

I hope this will help. Do not hesitate to write back with further questions.

Regards,
Ralitsa
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Nazmi
Top achievements
Rank 1
answered on 26 Jun 2014, 03:26 PM
I loved these progress bars. Thanks a lot.

Nazmi
Tags
ProgressBar
Asked by
Mike Baldini
Top achievements
Rank 2
Answers by
Nikolay
Telerik team
Nazmi
Top achievements
Rank 1
Ralitsa
Telerik team
Share this question
or