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

how to change set for colors in RadStackedDataBar programmatically?

1 Answer 61 Views
DataBar
This is a migrated thread and some comments may be shown as answers.
Navneet
Top achievements
Rank 1
Navneet asked on 20 Jan 2014, 03:07 AM
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>

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 22 Jan 2014, 09:44 AM
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 >>
Tags
DataBar
Asked by
Navneet
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or