Click here to Skip to main content
11,704,044 members (66,355 online)
Rate this: bad
Please Sign up or sign in to vote.
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?

Posted 5-Feb-13 2:42am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Hslldm at 5-Feb-13 9:05am
x:Class="DXWPFApplication3.MainWindow_2" i changed the name like this. But didn't solved.
Pete O'Hanlon at 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 at 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 at 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)

  Print Answers RSS
0 Maciej Los 530
1 OriginalGriff 510
2 Sergey Alexandrovich Kryukov 421
3 Andy Lanng 294
4 F-ES Sitecore 220
0 OriginalGriff 8,744
1 Sergey Alexandrovich Kryukov 7,747
2 CPallini 5,107
3 Maciej Los 4,716
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100