title: C# User Interface Printing Image on Screen Problem
body: <p>I am trying to print images when user clicks on buttons. The first click works fine and prints the image but other clicks do not work as I expect. Even I click on another button first image is shown. For example when I click to chef's it prints correct images then I click on veg but it still shows the images of chef's. What is the problem of this code? </p>
  
  <pre><code>public partial class MainWindow : Window, INotifyPropertyChanged
      {
          public ObservableCollection&lt;string&gt; selectedMenu = new ObservableCollection&lt;string&gt;();
  
          public ObservableCollection&lt;string&gt; ChefsMenu = new ObservableCollection&lt;string&gt;();
          public ObservableCollection&lt;string&gt; VegMenu = new ObservableCollection&lt;string&gt;();
          public ObservableCollection&lt;string&gt; LowCMenu = new ObservableCollection&lt;string&gt;();
          public ObservableCollection&lt;string&gt; orders = new ObservableCollection&lt;string&gt;();
  private void ChefsButtonDown(object sender, MouseButtonEventArgs e)
          {
              chefFlag = true;
              vegFlag = false;
              lowFlag = false;
              int len = ChefsMenu.Count;
              for(int i = 0; i &lt; len; i++)
              {
                  selectedMenu.Add(ChefsMenu[i]);
              }
              ShowPanel.ItemsSource = null;
              ShowPanel.Items.Refresh();
              ShowPanel.ItemsSource = selectedMenu;
          }
  
          private void VegButtonDown(object sender, MouseButtonEventArgs e)
          {
              chefFlag = false;
              vegFlag = true;
              lowFlag = false;
              int len = VegMenu.Count;
              for (int i = 0; i &lt; len; i++)
              {
                  selectedMenu.Add(VegMenu[i]);
              }
              ShowPanel.ItemsSource = null;
              ShowPanel.Items.Refresh();
              ShowPanel.ItemsSource = selectedMenu;
          }
  
          private void LowCButtonDown(object sender, MouseButtonEventArgs e)
          {
              chefFlag = false;
              vegFlag = false;
              lowFlag = true;
              int len = LowCMenu.Count;
              for (int i = 0; i &lt; len; i++)
              {
                  selectedMenu.Add(LowCMenu[i]);
              }
              ShowPanel.ItemsSource = null;
              ShowPanel.Items.Refresh();
              ShowPanel.ItemsSource = selectedMenu;
          }
  public event PropertyChangedEventHandler PropertyChanged;
          public void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
          {
              PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
          }
  </code></pre>
  
  <p>XAML</p>
  
  <pre><code>&lt;ItemsControl DockPanel.Dock="Left" Name="ShowPanel" ItemsSource ="{Binding Path=selectedMenu}" Width="690" Height="320"&gt;
                  &lt;ItemsControl.ItemsPanel&gt;
                      &lt;ItemsPanelTemplate&gt;
                          &lt;StackPanel Orientation="Horizontal"/&gt;
                      &lt;/ItemsPanelTemplate&gt;
                  &lt;/ItemsControl.ItemsPanel&gt;
                  &lt;ItemsControl.ItemTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;Border BorderBrush="LightGreen" BorderThickness="0.5"&gt;
                              &lt;TextBlock Text="{Binding Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" HorizontalAlignment="Left" Width="97" TextWrapping="Wrap"/&gt;
                          &lt;/Border&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/ItemsControl.ItemTemplate&gt;
              &lt;/ItemsControl&gt;
  </code></pre>