Reputation: 25
public partial class MainPage : UserControl { private MapLayer m_PushpinLayer;
public MainPage()
{
InitializeComponent();
base.Loaded += OnLoaded;
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
base.Loaded -= OnLoaded;
m_PushpinLayer = new MapLayer();
x_Map.Children.Add(m_PushpinLayer);
x_Map.MouseClick += OnMouseClick;
}
In above code what does base.loaded += Onloaded as well as base.loaded -= onloaded means ?
Thnks in advance for your reply
Upvotes: 0
Views: 83
Reputation: 722
This code basically attached a function OnLoaded to the Loaded event on the base class. Essentially, when the Loaded event occurs, the OnLoaded function handles it. The += attaches the handler to the event, the -= removes the handler from the event.
Check this http://msdn.microsoft.com/en-us/library/awbftdfh.aspx. It may help you understand events.
Upvotes: 1