Programmatically change Progress Bar color without themes

5 posts, 0 answers
  1. Mike Baldini
    Mike Baldini avatar
    6 posts
    Member since:
    Jan 2010

    Posted 02 Mar 2010 Link to this post

    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.
  2. Nikolay
    Nikolay avatar
    1805 posts

    Posted 05 Mar 2010 Link to this post

    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,
    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.
  3. Nazmi
    Nazmi avatar
    2 posts
    Member since:
    Oct 2013

    Posted 24 Jun 2014 in reply to Nikolay Link to this post

    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?

  4. Ralitsa
    Ralitsa avatar
    185 posts

    Posted 26 Jun 2014 Link to this post

    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.

    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.
  5. Nazmi
    Nazmi avatar
    2 posts
    Member since:
    Oct 2013

    Posted 26 Jun 2014 in reply to Ralitsa Link to this post

    I loved these progress bars. Thanks a lot.

Back to Top