Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:46:55+00:00 2026-06-14T11:46:55+00:00

When a new WPF Application project is created, MainWindow.xaml , App.xaml and their corresponding

  • 0

When a new WPF Application project is created, MainWindow.xaml, App.xaml and their corresponding code behind classes are automatically generated. In the App.xaml there is an attribute that defines which window is going to be run initially and by default, it’s StartupUri="MainWindow.xaml"

I have created a new Dispatcher class in the same project. At startup, I want the instance of that class Dispatcher to be constructed and then one of its method to run. That method would actually create and show the MainWindow window. So how do I modify the App.xaml or App.xaml.cs in order to make it happen? Or, if it cannot be done by App, how should I implement it? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:46:56+00:00Added an answer on June 14, 2026 at 11:46 am

    You can remove the StartupUri attribute from the App.xaml.

    Then, by creating an override for OnStartup() in the App.xaml.cs, you can create your new instance of your Dispatcher class.

    Here’s what my quick app.xaml.cs implementation looks like:

    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
          base.OnStartup(e);
    
          new MyClassIWantToInstantiate();
        }
      }
    }
    

    Update

    I recently discovered this workaround for a bug if you use this method to customize app startup and suddenly none of the Application-level resources can be found.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created new WPF Application witn two windows. MainWindow.xaml Window1.xaml Added one button in
Bear with me because I'm new to WPF/XAML. I'm trying to write a MainWindow.xaml
I'm new to WPF, and created a 1st simplistic WPF application that I want
When I create a new WPF application in Visual Studio 2012 the platform target
While designing a new WPF application I noticed exceptions not being thrown during data
I have window form in my WPF Application when I open new window from
I am new to wpf and i am working on first application i have
I am new to WPF and MVVM, and I am working on an application
I am new to WPF. I'm trying to build an application which has a
Doing the below will reproduce my problem: New WPF Project Add ListView Name the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.