Within my application, i use the hidden and visible porperties to make windows how or not show to the user. Now at some point, when i am in Window1, i want to make a check if there is still a instance of the main window, that is hidden. Googling, i found (also on SO) that i need to use this code:
Window deze = Application.Current.Windows.OfType<MainWindow>().Where(x => x.Name == "MainWindow").FirstOrDefault();
但无论哪一部分填满<代码>。 OfType<MainWindow> or for the MainWindow>
, 即使在肯定100%的情况下,也仍然无法返回。
Checking in the code of the main window, that is called in the solution explorer (visual express) "mainWindow.xaml" i see that the code looks like this:
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
//creating the exitmessage for use later on, after all, we want to use this in an other method.
public MainWindow()
{
......
}
I really have no clue at all, why that "Window deze" keeps returning null when im 100% sure there is a hidden instance of the main window.
Anyone got an idea on this one ? Im i just totally overlooking some logical solution ?
页: 1