Click here to Skip to main content
Rate this: bad
good
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?
 
Thanks.
Posted 5-Feb-13 3:42am
Hslldm393

1 solution

Rate this: bad
good
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.
  Permalink  
Comments
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)



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2014
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