When I call ShowRevertInventorySignDialogView()
through COMMAND, event throws ObjectNullException. I'm thinking that Object is not dispose as its assined to CurrentViewModel
property.
Both GetReport()
and ShowRevertInventorySignDialogView()
functions called by Command which are binded to Buttons. I'm pretty sure that GetReport()
function is called first so that object is created before raising the event.
What am I missing here?
class MainWindowViewModel : ViewModel{
public ViewModel CurrentViewModel
{
get { return currentViewModel; }
set { currentViewModel = value; NotifyPropertyChanged(); }
}
public void GetReport()
{
inventoryReportViewModel = new InventoryReportViewModel();
inventoryReportViewModel.OnStatusChange += Event_OnStatusChange;
CurrentViewModel = inventoryReportViewModel;
}
}
public class InventoryReportViewModel : InventoryBaseViewModel
{
public event EventHandler<StatusChangeEventArgs> OnStatusChange;
private void ShowRevertInventorySignDialogView()
{
OnStatusChange(this, new StatusChangeEventArgs("test",10));
....
....
}
}
XAML;
<ContentControl Content="{Binding Path=CurrentViewModel}" Margin="20 10 20 0"></ContentControl>