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.
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.
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.
“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.
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.
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();
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With