Solved

Passing multiple values using a Pagefunction

Posted on 2008-10-25
8
382 Views
Last Modified: 2013-12-17
Hi Guys,

Does anyone know how to pass MULTIPLE values using a Pagefunction? There are lots of examples for returning a single value, but I need to return multiple values.

Any help would be greatly appreciated.

Thanks,

Stephane Touya
0
Comment
Question by:MrTouya
  • 5
  • 3
8 Comments
 
LVL 16

Expert Comment

by:ororiole
ID: 22806225
You can use a collection. Here I have used a collection of string, but of course it can be whatever you want.
void doneButton_Click(object sender, RoutedEventArgs e)
{
    // Complete the page function and return data of type List<>
List<string> list = new List<string>()
{
"first",
"second",
"third"
};
    OnReturn(new ReturnEventArgs<List<string>>(list);
}
 
//and in the calling page you handle the return event
List<string> = e.Result

0
 

Author Comment

by:MrTouya
ID: 22807004
Good Idea! I will try it and let you know.
0
 

Author Comment

by:MrTouya
ID: 22807086
HI ororiole,

So Close. I realized that the values I am returning are of two different types. One is an interface type to a third party Engine and the other is enum to the engine type.  I am still stuck.

Stephane
0
 
LVL 16

Accepted Solution

by:
ororiole earned 500 total points
ID: 22808116
Then lets use a non generic collection that contains objects. You will need to test for the type when you remove the object. I didnt compile this, but you get the idea.

void doneButton_Click(object sender, RoutedEventArgs e)
{
   // Complete the page function and return data of type ArrayList
   MyClass myClass = new MyClass();
   MyEnum myEnum = MyEnum.one;

  ArrayList al = new ArrayList();
  al.Add(myClass);
  al.Add(myEnum);

  OnReturn(new ReturnEventArgs<ArrayList>(al);
}

//now in the calling page it looks something like this

ArrayList myList = e.Result;
object o = myList.Remove();
if ( o is MyClass )
{
  MyClass thisclass = (MyClass) o;
  //do something here
}
else
if ( o is MyEnum)
{
  MyEnum thisEnum = (MyEnum) o;
  //something else
}
else
{
  //what is this? :)
}




0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Closing Comment

by:MrTouya
ID: 31510048
Thanks. That did it :-)
0
 

Author Comment

by:MrTouya
ID: 22809175
Oops. one more questions. What namespace should I be using?

clr-namespace:System.Collections;assembly=mscorlib?
 
0
 

Author Comment

by:MrTouya
ID: 22809387
Hi ororile,
 I am close. Now I am getting this error right after the OnReturn event:
 Exception of type 'System.ExecutionEngineException' was thrown.
This is my code
ArrayList EngineValuesList = new ArrayList();
EngineValuesList.Add(_MyEngine);
EngineValuesList.Add(_selectedEngineType);
EngineValuesList.TrimToSize();
OnReturn(new ReturnEventArgs<ArrayList>(EngineValuesList));  
 
I am going to open up another question so you can get the credit.
 
Stephane
0
 
LVL 16

Expert Comment

by:ororiole
ID: 22810580
You found System.Collections I presume? sorry, I had a lot of weekend things to get done. :)
ExecutionEngineException? Hmm, have to think about that one a bit.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now