title: OxyPlot add PlotModel
body: <p>I am trying to add OxyPlot Chart dynamical, But it doesn't work.</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication8.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="MainWindow" Height="350" Width="525"&gt;
  &lt;Grid &gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="20"&gt;&lt;/RowDefinition&gt;
          &lt;RowDefinition&gt;&lt;/RowDefinition&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Grid.ColumnDefinitions&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;ItemsControl ItemsSource="{Binding TheList}" x:Name="MyGrid" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="Auto" Grid.Row="1"&gt;
          &lt;ItemsControl.ItemsPanel&gt;
              &lt;ItemsPanelTemplate&gt;
                  &lt;UniformGrid Rows="{Binding Path=Rows,Mode=TwoWay}" Columns="{Binding Path=Columns,Mode=TwoWay}"&gt;&lt;/UniformGrid&gt;
              &lt;/ItemsPanelTemplate&gt;
          &lt;/ItemsControl.ItemsPanel&gt;
      &lt;/ItemsControl&gt;
      &lt;StackPanel Orientation="Horizontal"&gt;
          &lt;Button Command="{Binding One}"&gt;1&lt;/Button&gt;
          &lt;Button Command="{Binding Four}"&gt;4&lt;/Button&gt;
          &lt;Button Command="{Binding Eight}"&gt;8&lt;/Button&gt;
      &lt;/StackPanel&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>Code look's like this. FourButton and EightButton doesn't work.</p>
  
  <pre><code>using GalaSoft.MvvmLight.Command;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  using System.ComponentModel;
  using System.Collections.ObjectModel;
  using OxyPlot.Wpf;
  using OxyPlot;
  namespace WpfApplication8
  {
  /// &lt;summary&gt;
  /// Interaction logic for MainWindow.xaml
  /// &lt;/summary&gt;
  /// 
  
  public partial class MainWindow : Window
  {
  
      public class ViewModelTest : INotifyPropertyChanged
      {
          private PlotModel plotModel;
          public PlotModel PlotModel
          {
              get { return plotModel; }
              set { plotModel = value; NotifyPropertyChanged("PlotModel"); }
          }
  
          private ObservableCollection&lt;PlotModel&gt; theList;
          public ObservableCollection&lt;PlotModel&gt; TheList
          {
              get { return theList; }
              set { theList = value; NotifyPropertyChanged("TheList"); }
          }
          private int rows;
          public int Rows
          {
              get { return rows; }
              set { rows = value; NotifyPropertyChanged("Rows"); }
          }
          private int columns;
          public int Columns
          {
              get { return columns; }
              set { columns = value; NotifyPropertyChanged("Columns"); }
          }
          public ViewModelTest()
          {
              PlotModel = new PlotModel();
              PlotModel.LegendTitle = "Legend";
              PlotModel.LegendOrientation = LegendOrientation.Horizontal;
              PlotModel.LegendPlacement = LegendPlacement.Outside;
              PlotModel.LegendPosition = LegendPosition.TopRight;
              PlotModel.LegendBackground = OxyColor.FromAColor(200, OxyColors.White);
              PlotModel.LegendBorder = OxyColors.Black;
  
              TheList = new ObservableCollection&lt;PlotModel&gt;();
              One = new RelayCommand(() =&gt; OneButton());
              Four = new RelayCommand(() =&gt; FourButton());
              Eight = new RelayCommand(() =&gt; EightButton());
          }
          public ICommand One { get; set; }
          public ICommand Four { get; set; }
          public ICommand Eight { get; set; }
  
  
          public event PropertyChangedEventHandler PropertyChanged;
          private void NotifyPropertyChanged(String info)
          {
              if (PropertyChanged != null)
              {
                  PropertyChanged(this, new PropertyChangedEventArgs(info));
              }
          }
          public void OneButton()
          {
              Rows = 1;
              Columns = 1;
              TheList.Clear();
              for (int i = 0; i &lt; 1; i++)
              {
                  TheList.Add(PlotModel);
              }
          }
          public void FourButton()
          {
              Rows = 2;
              Columns = 2;
              TheList.Clear();
              for (int i = 0; i &lt; 4; i++)
              {
                  System.Windows.Controls.Button newBtn = new Button();
                  newBtn.Content = i.ToString();
                  newBtn.Name = "Button" + i.ToString();
                  //TheList.Add(newBtn);
              }
          }
          public void EightButton()
          {
              Rows = 2;
              Columns = 4;
              TheList.Clear();
              for (int i = 0; i &lt; 8; i++)
              {
                  System.Windows.Controls.Button newBtn = new Button();
                  newBtn.Content = i.ToString();
                  newBtn.Name = "Button" + i.ToString();
                  //TheList.Add(newBtn);
              }
          }
      }
      public MainWindow()
      {
  
          DataContext = new ViewModelTest();
          InitializeComponent();
  
      }
  }
  </code></pre>
  
  <p>}
   Why chart isn't displaying? If i adding button's it work's fine. I also tryed to use template, but there was no effect.</p>