user1399377
user1399377

Reputation: 479

Open wpf window from other project

I have two separate project for example project1 and project2. Well i have a window1 in the project1 so how can i show this window1 from project2.

Upvotes: 8

Views: 12326

Answers (2)

Mark Hall
Mark Hall

Reputation: 54532

You just need to add a project reference to the project you want to call the other project from. You can then do something like this. I have 2 different Namespaces but something like this should work.

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        WpfApplication2.MainWindow newForm;

        public MainWindow()
        {
            InitializeComponent();

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            newForm = new WpfApplication2.MainWindow();

            newForm.Show();  // or newForm.ShowDialog();
        }
    }
}

Upvotes: 12

HichemSeeSharp
HichemSeeSharp

Reputation: 3318

What you need to do is to add Project 1 reference to Project 2 project and then call window1 as you're used to do (Don't forget before calling : you need using Project1; where you want to call window1 so the intellisense would find it easly for you)

Upvotes: 2

Related Questions