应用程序主窗口是空的WPF(使用微卡利) [英] Application MainWindow is null in WPF (using Caliburn Micro)

查看:411
本文介绍了应用程序主窗口是空的WPF(使用微卡利)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个WPF应用程序,我需要拿到一分,以控制内部的应用程序的主窗口。我使用的卡利微。



Application.Current.MainWindow



我怎样才能到主窗口
应用>参考< DIV CLASS =h2_lin>解决方案

这很有趣,我只是回答了这个在另一篇文章...尝试设置 Application.Current.MainWindow 加载事件在 MainWindow.xaml.cs 文件属性:

 私人无效MainWindow_Loaded(对象发件人,RoutedEventArgs E)
{
Application.Current.MainWindow =这一点;
}


I am developing a WPF application and I need to get a point to the main window of application inside a control. I am using Caliburn Micro.

Application.Current.MainWindow is null

How can I get a reference to the MainWindow of application in Caliburn Micro?

解决方案

That's funny, I've just answered this in another post... Try setting the Application.Current.MainWindow property in the Loaded event in the MainWindow.xaml.cs file:

private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    Application.Current.MainWindow = this;
}

这篇关于应用程序主窗口是空的WPF(使用微卡利)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆