I'm trying to populate a datagrid calling a function with RoutedEventArgs
event. So far it works, but I was expecting to reuse the function on a TabControl SelectionChanged
, but when I reference the previous function, I get a NullReferenceException
. 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:
private void BtnMostrar(object sender, RoutedEventArgs e)
{
ObservableCollection<EventoRubrica> cltEvtRubrica =
new ObservableCollection<EventoRubrica>();
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);
}