So my MainWindow with a datagrid is suppose to have an "add client" button and it will bring you to a new window and that window will ask information about the soon to be client and if I click the "save" button it should close the window and put the information to the datagrid on my MainWindow and I tried many things but I can't seem to get it right and I'm using wpf
public partial class GetInfo : Window
{
public GetInfo()
{
InitializeComponent();
}
public class Client
{
public string name { get; set; }
public string address { get; set; }
}
private void SaveBT_Click(object sender, System.EventArgs e)
{
MainWindow main = new MainWindow();
Client addClient = new Client();
addClient.name = NameTB.Text;
addClient.address = AddressTB.Text;
main.DataGridXAML.Items.Add(addClient);
this.Close();
}
}
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
private void LogOut_Click(object sender, RoutedEventArgs e)
{
LoginScreen logout = new LoginScreen();
logout.Show();
Close();
}
private void AddClient_Click(object sender, RoutedEventArgs e)
{
GetInfo infoget = new GetInfo();
infoget.Show();
}
}