{WPF}当我打电话给新窗口时它是空白的 [英] {WPF} When I a Call a New Window It's Blank
问题描述
我正在开发一个vs2010 WPF项目
我目前正在登录
登录还可以,但之后所谓的MainWindow是空的(但我设计的)在设计师中)
Project.MainWindow main = new 项目。主窗口();
App.Current.MainWindow = main;
this .Hide();
main.Show();
这个 .Close();
MainWindow我是被称为仅显示空白(白色屏幕)带边框
<前一行=xml>高度=550宽度=1000允许透明度=真ResizeMode =NoResize最高=真 WindowStyle =无>
但我设置它没有边框。
我搜索谷歌搜索答案
切换Wpf窗口
MainWindow main = new MainWindow();
App.Current.MainWindow = main;
this .Close();
main.Show();
i不知道为什么我的MainWindow是空的?
你好试试这个:
Project.MainWindow main = new Project.MainWindow();
main.Owner = this;
this.Hide();
main.Show();
构造函数中第二种形式的
不会删除它:
InitializeComponent();
和事件关闭时的第二个表单添加此项以显示主表单再次表示登录一个:
this.Owner.Show();
我很无语>
Jokler.007 是对的
要加载窗口的数据/设计,
永远不要忘记Inialize它的零件。因为如果没有,它将是空白。
MainWindow.xaml.cs
public partial class MainWindow :Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded( object sender,RoutedEventArgs e)
{
}
}
}
对不起我刚接触C#
I am working on a vs2010 WPF project
and I'm currently working on login
login is ok but after that the supposedly MainWindow is Blank(but i designed it in Designer)
Project.MainWindow main = new Project.MainWindow();
App.Current.MainWindow = main;
this.Hide();
main.Show();
this.Close();
MainWindow that i Called Show only Blank(WhiteScreen)with Border
Height="550" Width="1000" AllowsTransparency="True" ResizeMode="NoResize" Topmost="True" WindowStyle="None">
but i set it without border.
as I searched google for answer
to switch Wpf window
MainWindow main = new MainWindow();
App.Current.MainWindow = main;
this.Close();
main.Show();
i don't know but why my MainWindow is Blank?
hello try this :
Project.MainWindow main = new Project.MainWindow(); main.Owner = this; this.Hide(); main.Show();
in the second form in the constructor don't remove this :
InitializeComponent();
and the second form on the event close add this to show the main form again mean the login one :
this.Owner.Show();
I'm quite Speechless
Jokler.007 is right
To Load the Data/Design of the Window,
one should never forget to Inialize it's Component. because if not, it will be Blank.
MainWindow.xaml.cs
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { } } }
Sorry I'm just new to C#
这篇关于{WPF}当我打电话给新窗口时它是空白的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!