简体   繁体   中英

Mahapps Metro theme not appearing if using App_Startup in App.xaml

Have had Mahapps working for a while in this project in all windows, but as soon as I changed in apps.xaml

StartupUri = "MainWindow.xaml"    --/>       Startup = "App_Startup"

the theme is no longer there.

The program still works normally, does everything I need it to other than display the theme.

here is the App_Startup that I'm using to open the windows that don't have the themes.

public partial class App
{
    // Define Windows
    private readonly MainWindow _main = new MainWindow();
    private readonly Login _login = new Login();

    private void App_Startup(object sender, StartupEventArgs e)
    {
        Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
        Current.MainWindow = _login;

        _login.LoginSuccessful += _main.StartupMainWindow;

        _login.Show();
    }
}

Is there something I should change or add to help the theme start?

Edit: I'm assuming it has something to do with the Resource Dictionary that is in the App.xaml, those are all there but not loaded with the above code somehow?

Found that the issue is in fact with Resources.

To solve it for this, copy the resources into the window XAML as Window Resources.

Credit to the good people over at MahApps Gitter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM