[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 458
  • Last Modified:

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

0
Unimatrix_001
Asked:
Unimatrix_001
  • 2
1 Solution
 
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
 
Unimatrix_001Author Commented:
Sorted. In the App.xaml file I had to add in 'Startup="App_Startup"'
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now