WPF窗口名称更改 [英] WPF window name change

查看:806
本文介绍了WPF窗口名称更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有VS2012,我打开了一个名为mainwindow.xaml的WPF,我在其上添加了一个按钮,打开另一个WPF。



所以我添加了另一个WPF项目。但VS2012给它起了相同的名字:mainwindow.xaml。

按钮没有打开第二种形式,打开相同的表格。



属性中有一个名称部分,我从那里更改了名称。但它没有解决。



我该怎么办?



谢谢。

解决方案

虽然XAML文件不一样,但我怀疑命名空间会有所不同,所以当你打开它时,你总是可以完全限定另一个XAML名称: pre lang =c#> new SecondProject.Company.Class.MainWindow()。Show();

更好的选择是重命名MainWindow的第二个实例的实际物理类名称。为此,您必须在Code Behind文件中更改类的名称,并更改XAML文件中的x:Class属性以使用此新名称。


I have VS2012 and i opened a WPF named "mainwindow.xaml" and i added a button on it to open another WPF.

So i added another WPF project. But VS2012 gave it the same name :"mainwindow.xaml".
And button doesn''t open second form, opens the same form.

There is a name section in properties, i changed the name from there. But it didn''T solved.

What should i do?

Thanks.

解决方案

While the XAML files won''t be the same, I suspect the namespaces will be different, so you could always fully qualify the other XAML name when you open it:

new SecondProject.Company.Class.MainWindow().Show();

A better bet would be to rename the actual physical class name for the second instance of MainWindow. To do this, you have to change the name of the class in the Code Behind file, and change the x:Class attribute in the XAML file to use this new name.


这篇关于WPF窗口名称更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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