get the event's object
I have an event function and i want to use this for multiple objects. So in the event function i try to get the object source of the event to do the right action.
public void changed(BaseComponent c, Noesis.RoutedEventArgs args)
{
mybox = new ComboBox ();
"this is not a noesis code but it's like that in flash it's just for the example it doesn't work in noesis of course":
mybox = args as Target ();
String str = mybox.GetSelectedItem ().AsString();
Debug.Log(str);
}
public void changed(BaseComponent c, Noesis.RoutedEventArgs args)
{
mybox = new ComboBox ();
"this is not a noesis code but it's like that in flash it's just for the example it doesn't work in noesis of course":
mybox = args as Target ();
String str = mybox.GetSelectedItem ().AsString();
Debug.Log(str);
}
Re: get the event's object
If I understand you right and you just want to use the same method for the event handler of multiple framework elements such as ComboBox, I think in NoesisGUI v1.1 it should look like this:
But this would be considered a bad design in WPF. You should also have a look at bindings as these make everything more flexible and easier to use.
But perhaps I've got you completely wrong.
Code: Select all
public void changed(BaseComponent sender, Noesis.RoutedEventArgs args)
{
var myBox = sender.As<ComboBox>();
if (myBox == _comboBox1)
{
// do whatever you want
}
else if (myBox == _comboBox2)
{
// do whatever you want
}
}
But perhaps I've got you completely wrong.

-
-
sfernandez
Site Admin
- Posts: 3222
- Joined:
Re: get the event's object
Thanks for your help here Scherub
diesel76, does the example by Scherub explain what you are looking for?

diesel76, does the example by Scherub explain what you are looking for?
Who is online
Users browsing this forum: Ahrefs [Bot] and 1 guest