Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

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:
C#
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.
 
Share this answer
 
Comments
Hslldm 5-Feb-13 9:05am    
x:Class="DXWPFApplication3.MainWindow_2" i changed the name like this. But didn't solved.
Pete O'Hanlon 5-Feb-13 10:26am    
I assume you also changed the name in the code behind here? Your code to open this from the other side would be something like "new MainWindow_2().Show();".
Hslldm 5-Feb-13 10:47am    
VS underlines "MainWindow_2" and says "Namespace or Type couldn't be found"
But my second forms have that name:
----------------------------------------------------
public partial class MainWindow_2 : DXRibbonWindow
----------------------------------------------------

What's the problem?
Hslldm 5-Feb-13 9:13am    
Or can you just tell me the codes,for a button to open a new form.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900