SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

0
0

If there a way to bind series color/thickness to a custom control so the line color and thickness changes dynamically when user select a different color/thickness? I will need use this with the MVVM dataseries API.

  • You must to post comments
0
0

Yes there is, you just have to bind RenderableSeries.SeriesColor and StrokeThickness to a property in the viewmodel.

e.g.

<s:SciChartSurface>
   <s:SciChartSurface.RenderableSeries>
      <s:FastLineRenderableSeries SeriesColor="{Binding Color}" StrokeThickness="{Binding StrokeThickness}"/>
   </s:SciChartSurface.RenderableSeries>
</s:SciChartSurface>

Then in a viewmodel

public class MyViewModel : INotifyPropertyChanged
{ 
    private int _strokeThickness = 1;
    private Color _color = Color.FromArgb(0xFF, 0xFF, 0x66, 0x00);

    public int StrokeThickness 
    { 
       get { return this._strokeThickness; } 
       set
       { 
           this._strokeThickness = value;
           OnPropertyChanged("StrokeThickness");
       }
    }

    public Color Color 
    { 
       get { return this._color; } 
       set
       {
           this._color = value;
           OnPropertyChanged("Color");
       }
    }

    protected void OnPropertyChanged(string prop)
    {
        var handler = PropertyChanged;
        if (handler != null)
        {
             handler(this, new PropertyChangedEventArgs(prop));
        }
    }
}

I hope this helps!

  • JQuan
    Sorry Andrew, I think I asked the question too simplistically and thus the simplistic answer. I actually figure it out. Thanks.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.