dhamo
dhamo

Reputation: 181

How to Open XAML file from class file?

I have three project in one solution.

Project1 & Project2 & Project3.

In Project1 I have two .XAML files.

 1. Employee_Account.XAML
 2. Employee_Address.XAML

In Project2 I have one .XAML file.

 1.ViewEmployee.XAML

In Project3 I have one .cs file.

1. Method.cs

Method.cs --> Method Name

Public Void OpenEmployeeScree()
{
}

In Project2 --> ViewEmployee.XAML, I have one button click event. Inside this click event i Called Project3 method for OpenEmployeeScree().

E.g:

Project2 :

Public void Button_Click(object sender, RoutedEventArgs e)
{
  Project3 obj = new Project3();
  obj.OpenEmployeeScree();
}

when I click Project3-->ButtonClick event I would like to show Employee_Account.XAML.

How to do it.

Upvotes: 0

Views: 803

Answers (2)

ViVi
ViVi

Reputation: 4464

Try this. This is the code you need.

Employee_Account empAcc = new Employee_Account();
MainWindow newWindow = new MainWindow { Owner = this };
newWondiw.Content = empAcc;
newwindow.Show();

Upvotes: 2

Jai
Jai

Reputation: 8363

Although I have no idea why you would want to split all these things into 3 separate projects, but you can do this.

var acc = Project1_Namespace.Employee_Account();

Upvotes: 0

Related Questions