In the MainWindow
constructor, I am registering an event handler:
public partial class MainWindow : Window, INotifyPropertyChanged
{
public MainWindow()
{
InitializeComponent();
pageViewDocText = new PageViewDocText();
framePageDocFieldDetail.Content = pageViewDocText;
pageViewDocText.NewPageIRPRO += new GabeLib.SearchCls.DocEventHandler(ViewIPRO);
}
protected void ViewIPRO(string IRPOlink) // ...
}
public partial class PageViewDocText : Page, INotifyPropertyChanged
{
public event GabeLib.SearchCls.DocEventHandler NewPageIRPRO;
private void btn_PageBreakNext(object sender, RoutedEventArgs e)
{
// this fires but NewPageIRPRO is null
if (NewPageIRPRO != null)
{
NewPageIRPRO("dummylink");
}
}
}
But in PageViewDocText
, NewPageIRPRO
is null
What am I doing wrong?
From PageViewDocText
, I want to call MainWindow.ViewIPRO
.
This event handler fires and is registered the line below pageViewDocText.NewPageIRPRO +=
App.StaticGabeLib.Search.NewDocIRPRO += new GabeLib.SearchCls.DocEventHandler(ViewIPRO);
Looks like you are calling an event from another class (not listed) and there is a missing delegate.
Try this code:
public partial class MainWindow : Window, INotifyPropertyChanged
{
public MainWindow()
{
InitializeComponent();
pageViewDocText = new PageViewDocText();
framePageDocFieldDetail.Content = pageViewDocText;
pageViewDocText.PageBreakNext += new PageBreakNext(ViewIPRO);
}
protected void ViewIPRO(string IRPOlink) // ...
}
public partial class PageViewDocText : Page, INotifyPropertyChanged
{
public delegate void PageBreakNext(string IRPOlink);
public event PageBreakNext PageBreak;
private void btn_PageBreakNext(object sender, RoutedEventArgs e)
{
// this fires but NewPageIRPRO is null
if (PageBreak != null)
{
PageBreak("dummylink");
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With