I have an app that we are adding multiple series' to a ScatterLineSeries in the code behind when our VM is either added to or removed from. Also, our VM contains the "Series Name' that is editable in another portion of the UI. I have everything wired up and working EXCEPT automatic changing of the series name in the legend when our Observable Collection is changed.
My ViewModel is similar to this
Public ObservableCollection<ScatterPointCollection> DataSerieses
public class ScatterPointCollection : ObservableCollection<ScatterPointData>, INotifyPropertyChanged
{
public string XField {get; set; }
public string SeriesTitle { get; set; }
...
}
then in code behind, whenever I add a series I loop through the 'DataSerieses' collection and create a new ScatterLineSeries...
loop
ScatterLineSeries sls = new ScatterLineSeries();
sls.Title = dataSeries.SeriesTitle;
end loop
This provides me with the correct title in the legend initially, BUT, if I change the dataSeries.Title, it is not reflected in the legend until the chart is redrawn. I realize this is because I have not properly bound the slc.Title to the DataSeries properly, but there is no "SetBinding()" method available on the slc.Title property - it isjust type object.
How can I do this binding in code behind? I had it working in XAML, but in order to handle multiple series' I need to do it in code behind!
thanks
Rod
Sorry about the post, but in one last ditch effort to fix the issue - the solution slapped me in the face. in the above code snippet, substitute the following, and everything works
TextBlock txtbl = new TextBlock();
txtbl.DataContext = DataSeries;
txtbl.SetBinding( TextBlock.TextProperty, new Binding("SeriesTitle") );
sls.Title = txtbl;
Hello Rod,
Thank you for your post. I am very glad that you hae managed to solve the issue that you were having. Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support