This discussion was imported from CodePlex
richardfen wrote at 2014-03-25 00:18:
I want to create a databinding programmatically for the LineSeries.Color property. The LineSeries.Color property must be a dependency property because you can bind to it in XAML. However, if I want to create a binding dynamically in code-behind, I need the static property LineSeries.ColorProperty. For example, the WPF TextBox.Text has an analogous TextBox.TextProperty. But Intellisense shows no LineSeries.ColorProperty.
objo wrote at 2014-03-25 20:58:
OxyPlot.Wpf.Series.ColorProperty. It is public and the type is
richardfen wrote at 2014-03-26 19:35:
thanks for your quick reply. I tried your solution and in order to get it to work we must use OxyPlot.Wpf.LineSeries (because it a DependencyObject and that is required for DataBinding). I used the following code:
This code compiles perfectly but when I try to add the LineSeries to the model it won't compile:
var ls = new OxyPlot.Wpf.LineSeries(); var b = new Binding(); b.Source = mySourceObject; b.Path = new PropertyPath("Color"); b.Mode = BindingMode.TwoWay; ls.SetBinding(OxyPlot.Wpf.Series.ColorProperty, b);
I get an error telling me that "ls" is the wrong type. It is expecting the non-WPF LineSeries. I have looked for a WPF version of PlotModel but can't find any. Thanks for you help.
PlotModel model model.Series.Add(ls)
objo wrote at 2014-03-26 20:55:
No, you cannot add a
OxyPlot.PlotModel. Try adding the "ls" to the
Seriescollection in your
Customer support service by UserEcho