Gradient Background in general - is it possible?

2 posts, 0 answers
  1. Michael
    Michael avatar
    12 posts
    Member since:
    Oct 2018

    Posted 19 Dec 2019 Link to this post


    I played around with your Gauge control and noticed it has a gradient range. But do you have an option to set a gradient background on other controls - it should be "easy" since you already developed the gradient feature?  

  2. Lance | Team Lead - US DevTools Support
    Lance | Team Lead - US DevTools Support avatar
    1070 posts

    Posted 19 Dec 2019 Link to this post

    Hi Michael,

    This is totally doable. I have two options for you:

    • Use the RadSweepGradientBrush (easy, can be done in XAML)
    • Use the SkiaSharp drawing libraries (harder, is done in C#, but more powerful)

    Telerik Option - Path & SweepGradientBrush

    Let me show you how to use our option. this is lightweight and easy to use. Just create a RadPath element/shape and use a RadSweepGradientBrush to fill it.

    As an example of it in action, visit the RadPath Styling documentation. For your convenience, here's the code example from that article:

    <telerikPrimitives:RadPath x:Name="gradientPath"
                               Geometry="{x:Static telerikInput:Geometries.Diamond}">
                    <Point>0.5, 0.5</Point>


    This is not a Xamarin.Forms.Color object that you can set on any plain Xamarin.Forms View element's BackgroundColor property. If you want to make a gradient background, you'll need to place a RadPath there so you can use the gradient brush inside it.

    For example, let's say you wanted a gradient sweep on a Grid background, you'd place the RadPath at the bottom of the Grid's children:

      <RadPath Fill="Your_Gradient" />
      <TheOtherStuffHere />

    Microsoft Option - SkiaSharp

    If this is not sufficient for your needs, you can use the Xamarin.Forms SkiaSharp library directly.  This option is a bit more complicated because you're manually handing the surface and paint event, but it will achieve just about any custom drawing options you need.

    Visit the following amazing Microsoft documentation article (I think it was written by Charles Petzold).


    Wrapping Up

    I hope I was able to answer your question. If you have any trouble using the Path or SweepGradient, feel free to open a support ticket and get one-on-one help from the developers and support team.

    Lance | Team Lead - US DevTools Support
    Progress Telerik

    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 Feedback Portal and vote to affect the priority of the items
Back to Top