How to Raise Event in WP8
As title, in WP8 there is no RaiseEvent() method. So, I can't do something like that. I need to activate an event in code.
Please help me!
How to Raise Event in WP8
As title, in WP8 there is no RaiseEvent() method. So, I can't do something like that. I need to activate an event in code.
Please help me!
You need to use Event-Delegate mechanism of .Net for this do like this:
//Declare Delegate and Event like this:
public delegate void YourDelegate();
public event YourDelegate YourEvent;
// Fire YourEvent from your code like this:
if (YourEvent!= null)
{
YourEvent();
}
Say you did this in YourClass.cs
then in suppose MainPage.xaml.cs:
YourClass object=new YourClass();
// Register HttpEvent event
object.YourEvent+= Handler_YourEvent;
add event handler in MainPage.xaml.cs:
void Handler_YourEvent()
{
//code to handle event
}
Hope this Helped you.
Suppose if you want to have a Tap Event,
use += to attach event handler in C#
Events for Windows Phone 8