Open wpf window from another project

I have two separate projects, for example project1 and project2. Well, I have window1 in project1, since I can show this window1 from project2.

+5
source share
2 answers

You just need to add a link to the project for the project from which you want to call another project. Then you can 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();
        }
    }
}
+9
source

What you need to do is add the Project 1 link to the Project 2 project, and then call window1, as you are used to (don't forget before calling: you need using Project1;where you want to call window1 so that intellisense will find this easy for you)

+1

All Articles