Navigating from Page/ Page Function to PageFunction Null Reference Exception occurs

StackOverflow https://stackoverflow.com/questions/19222611

  •  30-06-2022
  •  | 
  •  

Frage

Page.cs

private void PageButton_Click(object sender, RoutedEventArgs e)
{
    PageFunction pageFunction = new PageFunction();
    pageFunction.Return += new ReturnEventHandler<String>(pageFunction_Return);
    this.NavigationService.Navigate(pageFunction);
}

static void pageFunction_Return(object sender, System.Windows.Navigation.ReturnEventArgs<String> e)
{
    String returnedVaule = e.Result;
    MessageBox.Show(returnedVaule);
}

PageFunction.cs

private void PageFunctionButton_Click(object sender, RoutedEventArgs e)
{
    OnReturn(new ReturnEventArgs<string>("Returned"));
}

As Shown above i have a Page and a PageFunction.

On PageButton_Click of Page.cs, i am navigating to PageFunction, But after the execution of the whole PageButton_Click event, a null reference exception (i.e, Object reference not set to an instance of an object).

And i dont know why this exception ocurred.

Help me out with this problem.

Thanks.

War es hilfreich?

Lösung

Remember -> pagefunction<string> it may help you.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top