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 3975672
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:42:47+00:00 2026-05-20T04:42:47+00:00

How can this be done Login window appears first and if every thing is

  • 0

How can this be done

Login window appears first and if every thing is fine just close login window and open second Main window.
in win forms we modify program.cs but in wpf there is no program.cs.

Any solutions.?

Actully i did most of the work in the window that is created By default and now want to make it secondary(mean it should appear and then close when wanted giving control to new window)

   <Application x:Class="DevnMark_V1._0.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             Startup="Application_Startup">

    <Application.Resources>

    </Application.Resources>
</Application>



 public partial class App : Application
    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            var login = new MainWindow();
            login.ShowDialog();
            if (myAppSett.Default.validated == true)
            {
            var mainWindow = new DevNMarkMainWindow();              
                mainWindow.ShowDialog();
            }
        }

Login Window start XML

<Window x:Class="DevnMark_V1._0.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        xmlns:local="clr-namespace:Progress"
        Title="MainWindow" Height="292" Width="563" WindowStyle="None" BorderBrush="#FF0A6277" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Topmost="True">

Exception occurs when i close Login window and occurs at point InitializeComponent();of second window when it is viewed when it is going to be initilized

  • 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-05-20T04:42:47+00:00Added an answer on May 20, 2026 at 4:42 am

    There may be no program.cs, but there is an App.xaml.cs in the default WPF program template and you can do the same thing there.

    What you want to do is remove StartupUri="LoginWindow.xaml" from App.xaml and then modify App.xaml.cs’s constructor to invoke your login window and your main window, like this:

    public App() : base() {
        bool authenticated = false;
        LoginWindow login;
        while (!authenticated)
        {
            login = new LoginWindow();
            login.ShowDialog();
            authenticated = ValidUser(login.username, login.password);
        }
    
        MainWindow main = new MainWindow(login.username);
        main.ShowDialog();
    }
    

    The above example assumes you’ve added username and password as public properties to LoginWindow, and that you’ve modified MainWindow’s constructor to take a parameter.

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

Sidebar

Related Questions

I've done numerous searches and I realize that I can just download this file
Can this be done by setting a property? I'd prefer that approach then to
Can this be done w/ linqtosql? SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP
This isn't working. Can this be done in find? Or do I need to
Maybe this cannot be done, but please help or suggest how this can be
I don't think this can be done cleanly, but I'll ask anyway. I have
can ASP.NET controls be used with generics? Never seen this done and want a
I'm sure I've done this before, but can't find any example of it! Grrr...
Has anyone seen this before - and can anything be done about it? This
The default [1..5] gives this [1,2,3,4,5] and can also be done with the range

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.