title: How can I call one function from other function with RoutedEventArgs in C#?
body: <p>I'm trying to populate a datagrid calling a function with <code>RoutedEventArgs</code> event. So far it works, but I was expecting to reuse the function on a TabControl <code>SelectionChanged</code>, but when I reference the previous function, I get a <code>NullReferenceException</code>. I think the event was handled before on TabControl event, so I'm stuck on this puzzle, since how could I reap the previous event. Here are the functions:</p>
  <pre class="lang-cs prettyprint-override"><code>private void BtnMostrar(object sender, RoutedEventArgs e)
  {
      ObservableCollection&lt;EventoRubrica&gt; cltEvtRubrica =
          new ObservableCollection&lt;EventoRubrica&gt;();
  
      using (var db = new EventoRubricaContext())
      {
          var evts = db.EventoRubricas;
          foreach(var evt in evts)
          {
              cltEvtRubrica.Add(evt);
          }
      }
  
      evtDataGrid.ItemsSource = cltEvtRubrica;
  }
  
  private void tbCtrl_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
  {
      BtnMostrar(sender, e);
  }
  </code></pre>