Custom args to WindowClosedEventArgs

4 posts, 0 answers
  1. Michael Fooks
    Michael Fooks avatar
    17 posts
    Member since:
    Dec 2009

    Posted 15 Mar 2010 Link to this post

    When I use the WindowClosedEventArgs I need to be able to pass my own variable all the way through so i can use the variable on close.  Can we get an "arg" parameter or something to do this? ATM it looks like i'll have to make a bunch of member variables to hold the state.
  2. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 18 Mar 2010 Link to this post

    Hello Bronwen Zande,

    Can you elaborate more on what you try to achieve? What do you mean with "I need to be able to pass my own variable all the way through so i can use the variable on close"
    Do you need to expose value from some control that is inside RadWindow and populate it on Closed event? If this is your case you can use Tag property to store some value in closed event and use it after that.

    Let us know if that is not your case.

    All the best,
    Hristo
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Michael Fooks
    Michael Fooks avatar
    17 posts
    Member since:
    Dec 2009

    Posted 18 Mar 2010 Link to this post

    I don't see a tag property on the WindowClosedEventArgs?
    I only see DialogResult and PromptResult?

    My scenario is...

    I'm in Function A which has a parameter of say _resultObject
    Under a certain condition I want to prompt for a response and if the response is true execute function B but function B needs access to _resultObject. ATM the only way i can do this is to make a member variable.
    So what I want to be able to do is as follows:

    public void MyFunctionA(var resultObject)
    {
        if (needtoAskAQuestion)
        {
            RadWindow.Confirm(new EventHandler<WindowClosedEventArgs>(OnMyFunctionAClosed(arg=resultObject));
        }
        else
        {
            FunctionB(resultObject);
        }

     

     

    protected override void OnMyFunctionBClosed(object sender, WindowClosedEventArgs e)

     

    {

     

     

        if (e.DialogResult == true
        {
            FunctionB(e.arg);
        }
    }

     



        private void FunctionB(var resultObject)
        {
               // do stuff with result object.
        }
    }
  5. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 19 Mar 2010 Link to this post

    Hello Bronwen,

     You could also use an anonymous method instead - this will let you use your local variable. Please refer to the following code:

    public void MyFunctionA(var resultObject)
    {
        if (needtoAskAQuestion)
        {
            RadWindow.Confirm(new EventHandler<WindowClosedEventArgs>((s, e) =>
    {
    if (e.DialogResult == true)
        {
            FunctionB(resultObject);
        }
    });
        }
        else
        {
            FunctionB(resultObject);
        }
     
        private void FunctionB(var resultObject)
        {
               // do stuff with result object.
        }
    Hope this helps!

    Kind regards,
    Miroslav Nedyalkov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top