Capturing the App_Startup event

Hi,

I've got a generated WPF program and in the app.g.cs file I've got the first block of code and in App.cs I've got the second block of code. How can I capture the startup event in app.cs - I can't really modify app.g.cs because it is auto-generated.

Thanks,
Uni
/************************************************************************************************
namespace MyApp{
  
    /// <summary>
    /// App
    /// </summary>
    public partial class App : System.Windows.Application {
        
        /// <summary>
        /// Application Entry Point.
        /// </summary>
        [System.STAThreadAttribute()]
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        public static void Main() {
            MyApp.App app = new MyApp.App();
            app.Run();
        }
    }
}
************************************************************************************************/
 
/************************************************************************************************
namespace MyApp
{
    public partial class App : Application
    {
        void App_Startup(object sender, StartupEventArgs e)
        {
                //Stuff here...
        }
    }
}
************************************************************************************************/

Open in new window

LVL 3
Unimatrix_001Asked:
Who is Participating?
 
Unimatrix_001Connect With a Mentor Author Commented:
Sorted. In the App.xaml file I had to add in 'Startup="App_Startup"'
0
 
Juan_BarreraCommented:
Hi Unimatrix,

As those classes are declared partial, you can decalre a public class of the same name to complement it.

Have a look at this link for more information: http://msdn.microsoft.com/en-us/library/wa80x488.aspx

I hope this helps



0
 
Unimatrix_001Author Commented:
Hi Juan,

I'm aware of how partial classes work, but I don't understand the relevance to the problem?

Thanks,
Uni
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.