locked
Pass data from popup to main usercontrol? RRS feed

  • Question

  • I have a usercontrol that launches a popup control:

    private WelcomeScreen myWelcomeScreen;
    void StartPage_Loaded(object sender, RoutedEventArgs e)
    {
    myWelcomeScreen = new WelcomeScreen();
    myWelcomeScreen.Show();
    }


    In this usercontrol the user select various things and I calculate a result that I want to pass back to the main usercontrol when the user clicks on the "close" button in my popup:

    This is in my popup controls button event:
    private void myButton_Click(object sender, RoutedEventArgs e)
    {
    this.myResult = calculatedResult;
    myPopup.IsOpen = false;
    }


    So the question is how do the mainapplication know when I click the close button in the popup window? Create my own event?
    Tuesday, April 14, 2009 1:12 PM

Answers

  • One way is to declare a delegate method in your usercontrol and pass it to the popupcontrol.  When the OK is clicked call the delegate method with the return arguments.

     

    Tom

     

    Tuesday, April 14, 2009 1:53 PM

All replies

  •  Yep, you've got it. At least that's the way I'm doing it. Do you need help with the event itself?

    Tuesday, April 14, 2009 1:47 PM
  • One way is to declare a delegate method in your usercontrol and pass it to the popupcontrol.  When the OK is clicked call the delegate method with the return arguments.

     

    Tom

     

    Tuesday, April 14, 2009 1:53 PM
  • I have looked into events but it doesn't seems like you can create a custom bubbling event in SL2? The delegate method sounds like a good idea.
    Tuesday, April 14, 2009 6:58 PM