Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The second window is closed… #26

Closed
ywxt opened this issue Jul 8, 2018 · 4 comments
Closed

The second window is closed… #26

ywxt opened this issue Jul 8, 2018 · 4 comments

Comments

@ywxt
Copy link

ywxt commented Jul 8, 2018

Hi,
I was in trouble.

Try the following code.

    class Program
    {
        static void Main(string[] args)
        {
            var app=new Application();
            var win=new Window1();
            app.Run(win);
        }
    }

    class Window1:Window
    {
        private readonly Button _btn=new Button("Show Window2");
        public Window1() : base("Window1") => InitializeComponent();

        protected sealed override void InitializeComponent()
        {
            base.InitializeComponent();
            Child = _btn;
            _btn.Click += (sender, args) =>
            {
                var window2 = new Window2();
                window2.Show();
            };
        }
    }

    class Window2:Window
    {
        public Window2():base("Window2"){}
    }

After I closed the window2,the application exited.Why?

Also,the application cannot show Chinese.

Thank in advance for any help.

@simplexidev
Copy link
Owner

I noticed you didn't use the right Window constructor. Try changing your base constructor call to base("Window1", 600, 400, true)

@simplexidev
Copy link
Owner

The fourth parameter is used to determine whether a menustrip is displayed on the window or not.

@ywxt
Copy link
Author

ywxt commented Jul 8, 2018

Thank you.It is 4:10 now.I will test the code in the morning when I will give you a reply.

@simplexidev
Copy link
Owner

Refer to #25, as it is the same issue. Marked as a duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants