Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 820
user1399377 Avatar asked Jul 20 '12 14:07

user1399377


People also ask

How can I access a control in WPF from another class or window?

If you want to access a control on a wpf form from another assembly you have to use the modifier attribute x:FieldModifier="public" or use the method proposed by Jean. Save this answer. Show activity on this post. This may be a slightly different answer, but let's think about why we need to pass data between forms.

How do I display a WPF window?

When a Window is created at run-time using the Window object, it is not visible by default. To make it visible, we can use Show or ShowDialog method. Show method of Window class is responsible for displaying a window.

Is WPF discontinued?

“WPF would be dead in 2022 because Microsoft doesn't need to be promoting non-mobile and non-cloud technology. But WPF might be alive in that sense if it's the best solution for fulfilling specific customer needs today. Therefore, having a hefty desktop application needs to run on Windows 7 PCs with IE 8.

How do I open a WPF file in my browser?

Open Windows Explorer, go to the folder that contains the compiled version of your WPF Browser application and double-click the application (the . xbap file). This will launch the application.


1 Answers

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();
        }
    }
}
like image 87
Mark Hall Avatar answered Oct 17 '22 08:10

Mark Hall