CardboardHammer had it right. The visual ide will change that code on a whim, has nothing to do with ram.
There are two parts to the page you need to be aware of.
InitializeComponent <- DO NOT MODIFY
Page_Init <- HERE YOU CAN PUT YOUR HANDLERS
Page_Init actually calls InitializeComponent (doesn't show visibly sometimes, because it does so by default), so insert your handlers after that call inside the Page_Init event.