I feel like I am missing something very fundamental here, but I can't seem to find an answer.
When my app launches, I want a second window based on existing xaml to open in addition to MainWindow.xaml. I've found a lot about using code-behind to create a NEW window, but I want to open a window that is predefined in another xaml file.
Both are using MahApps and are defined as
<Controls:MetroWindow x:Class=...
...
</Controls:MetroWindow>
The second window is called ControlWindow.xaml and sits in the root with MainWindow.xaml
Thank you
EDIT:
When trying to create and show the window in the App_Startup event in app.xaml.cs, even though the window inherits from the same class as MainWindow.xaml, it does not have the Show() method available.
MainWindow.xaml.cs
using MahApps.Metro.Controls;
namespace RollCallDisplayDemo
{
public partial class MainWindow : MetroWindow
{
public MainWindow()
{
InitializeComponent();
}
}
}
ControlWindow.xaml.cs
using MahApps.Metro.Controls;
namespace RollCallDisplayDemo
{
public partial class ControlWindow : MetroWindow
{
public ControlWindow()
{
InitializeComponent();
}
}
}
App.xaml.cs
using System.Windows;
using GalaSoft.MvvmLight.Threading;
namespace RollCallDisplayDemo
{
public partial class App : Application
{
void App_Startup(object sender, StartupEventArgs e)
{
MainWindow NewWindowA = new MainWindow();
ControlWindow NewWindowB = new ControlWindow();
}
static App()
{
DispatcherHelper.Initialize();
}
}
}
NewWindowA acts as you would expect and allows a new instance to be created and shown. NewWindowB only has the InitializeComponent method available, nothing else which should inherited from the MetroWindow class.