title: Making a graph from a file with values in WPF
body: <p>Is there a way you can plot a graph/chart with WPF, I have a file with values, so I want the output to look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/JUF0x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JUF0x.png" alt="enter image description here"></a></p>
  
  <p>This XAML code:</p>
  
  <pre><code>&lt;Grid&gt;
          &lt;ItemsControl ItemsSource="{Binding Lines}" Margin="44,102,40,205" Grid.RowSpan="2"&gt;
              &lt;ItemsControl.ItemsPanel&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;Canvas Background="White"/&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/ItemsControl.ItemsPanel&gt;
              &lt;ItemsControl.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Line X1="{Binding From.X}" Y1="{Binding From.Y}"
                        X2="{Binding To.X}" Y2="{Binding To.Y}"
                        Stroke="DarkGray" StrokeThickness="3"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ItemsControl.ItemTemplate&gt;
          &lt;/ItemsControl&gt;
      &lt;/Grid&gt;
  </code></pre>
  
  <p>My ViewModel that should have all of the implementation drawing a graph:</p>
  
  <p>My idea was to have a collection of lines, but I then froze, and couldn't implement a good solution.</p>
  
  <p>I would read values from a txt file, but I do not know how should I pass them so they can be drawn on the graph.</p>
  
  <pre><code>  public ObservableCollection&lt;Line&gt; Lines { get; private set; }
  
    Lines = new ObservableCollection&lt;Line&gt;
              {
                  // I would add new lines here
  
              };
  </code></pre>
  
  <p>I have no experience when it comes to plotting graphs, so every advice would be a huge help to me</p>