This is a migrated thread and some comments may be shown as answers.

Custom args to WindowClosedEventArgs

3 Answers 145 Views
Window
This is a migrated thread and some comments may be shown as answers.
Michael Fooks
Top achievements
Rank 1
Michael Fooks asked on 16 Mar 2010, 04:49 AM
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.

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 18 Mar 2010, 01:48 PM
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.
0
Michael Fooks
Top achievements
Rank 1
answered on 19 Mar 2010, 12:26 AM
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.
    }
}
0
Miroslav Nedyalkov
Telerik team
answered on 19 Mar 2010, 02:44 PM
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.
Tags
Window
Asked by
Michael Fooks
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Michael Fooks
Top achievements
Rank 1
Miroslav Nedyalkov
Telerik team
Share this question
or