Bence Heszpuk
Bence Heszpuk

Reputation: 35

How can I set items(textbox, img...) on the second (window2) window?

I have a mainwindow, and when it starts, i want to open another one, and put something on it. how it is possible if i declare the second window like that:

public MainWindow()
{
    Window Window2 = new Window();
    Window2.Show();
    InitializeComponent();
}

Upvotes: 0

Views: 29

Answers (1)

mm8
mm8

Reputation: 169390

You can set the Content property of the new window to anything you want, for example a UserControl that you have created using the Project->Add menu in Visual Studio:

public MainWindow()
{
    InitializeComponent();

    Window win = new Window() { Width = 100, Height = 100 };
    win.Content = new UserControl1();
    win.Show();
}

Upvotes: 1

Related Questions