how to change set for colors in RadStackedDataBar programmatically?

2 posts, 0 answers
  1. Navneet
    Navneet avatar
    2 posts
    Member since:
    Nov 2013

    Posted 19 Jan 2014 Link to this post

    How can I do the same thing of building a BrushCollection and assigning to RadStackedDataBar programmatically in code behind. Thanks for answers.

    <telerik:RadStackedDataBar
        Name="xStackedDataBar"
        Grid.Row="1"
        Grid.Column="1"
        Minimum="-20"
        Maximum="20"
        ValuePath="BarValue"
        ToolTipPath="ToolTipItem"
        Margin="10,5">
        <telerik:RadStackedDataBar.BarBrushes>
            <databars:BrushCollection>
              <SolidColorBrush Color="SlateBlue" />
              <SolidColorBrush Color="AntiqueWhite" />
              <SolidColorBrush Color="Aqua" />
              <SolidColorBrush Color="Green" />
              <SolidColorBrush Color="Blue" />
     
            </databars:BrushCollection>
        </telerik:RadStackedDataBar.BarBrushes>
    </telerik:RadStackedDataBar>

  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 22 Jan 2014 Link to this post

    Hello Navneet,

    You can accomplish your requirement by adding the brushes in the BarBrushes collection of the StackedDataBar. Please, note that by default the collection holds several brushes, which you will first
    need to remove, otherwise they will be applied before your brushes. Take a look at the code sample demonstrating this approach:
    public MainWindow()
    {
        InitializeComponent();
     
        // Set the items source
        this.xStackedDataBar.ItemsSource = new ObservableCollection<double>
        {
            -10, 2, 3, 4, 10
        };
     
        // Clear the default brushes
        this.xStackedDataBar.BarBrushes.Clear();
     
        // Add new brushes
        this.xStackedDataBar.BarBrushes.Add(Brushes.Aqua);
        this.xStackedDataBar.BarBrushes.Add(Brushes.Bisque);
        this.xStackedDataBar.BarBrushes.Add(Brushes.BurlyWood);
        this.xStackedDataBar.BarBrushes.Add(Brushes.Coral);
        this.xStackedDataBar.BarBrushes.Add(Brushes.Orange);
    }

    On a side note, I noticed that you have opened the same thread in the Chart section of the forum, but I think it would be better if we continue the communication for the StackedDataBar in the DataBar section. That's why we are going to remove the other thread. However, please feel free to open a new thread in the Chart section if you have any Chart-related questions.

    Regards,
    Martin Ivanov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top