Reputation: 47
I have two "windows" in my program, 1st being the main page, which the user should see on start and 2nd is the small window, that I need to open when a person presses certain Button.
Main window is "MainWindow" Second window is "Window2"
I have created a xaml file for Window2 where I have the layout (Window2.xaml), but I don't know how to specify this xaml file when creating the window
In oder to open new window I used code from this question
private void sessionWieserherstellenBtn_Click(object sender, RoutedEventArgs e)
{
var window2 = new Window();
window2.Content = new TextBlock() { Text = "Hello" };
window2.Activate();
}
The problem is that it creates a window with just "Hello" TextBlock, since the content is set to that TextBox.
Is there any way to Basically do something like:
window2.Content = Window2.xaml
?
And also can I "link" Window2.cs file there?
Upvotes: 0
Views: 658
Reputation: 47
I was able to make it work with this code:
private void sessionWieserherstellenBtn_Click(object sender, RoutedEventArgs e)
{
var newWindow = new Window2();
newWindow.Activate();
}
Upvotes: 1