Programmatically add graph to XAML form C#

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

SheDan wrote at 2014-04-08 22:47:

Hello there!
I have to add different graphs in each new tab in TabControl. So I can't just write in XAML something like this:
  <oxy:Plot x:Name="Plot1" Title="A Graph" Model="{Binding PlotModel}">
I tried adding to Canvas using .Children.Add() but it doesn't work >_<

How can I add graph to my form from C# code during the runtime??

everytimer wrote at 2014-04-09 22:16:

Check ANY example.

In ViewModel:
PlotModel.Series.Add(ls);

SheDan wrote at 2014-04-09 22:27:

Oh no! You didn't get it. I have to declare new Plot from the C# code and then add it to Canvas and so on. I mean when I compelling my project there are not Plot blocks at all!

everytimer wrote at 2014-04-10 20:43:

You can add to the Model of your Plot then:
MyPlot1.Model.Series.Add(ls);
You should be using templates and bind a collection of PlotModels to a custom UserControlm