Help with WPF LIST and datagrid

  • Thread starter Thread starter Miuten
  • Start date Start date
M

Miuten

Guest
hi, iam creating a WPF for create a new clients. (Name, age, etc), and put that info on a datagrid. Its work fine if i do only in a single WPF window. The problem is i need show that datagrid on another WPF window. So... i want when i put "save usser" in another window appear the datagrid with the values.

I was trying to call the list of the clients (create in the main window) to the second window (where the datagris need to be)


this is my code actually with the datagrid in the same window:



namespace ClientesWPF
{
/// <summary>
/// Lógica de interacción para MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
List<Clientes> lista = new List<Clientes>();

public MainWindow()
{
InitializeComponent();
}



private void Btn_agregar_Click(object sender, RoutedEventArgs e)
{
Clientes cli = new Clientes();
cli.rut = txt_rut.Text;
cli.razonsocial = txt_razon.Text;
cli.direccion = txt_direccion.Text;
cli.telefono = int.Parse(txt_telefono.Text);
cli.combo = cbx.Text;

lista.Add(cli);
MostrarPersonas();
}

public void MostrarPersonas()
{
dg_tabla.ItemsSource = lista;
dg_tabla.Items.Refresh();
}

private void Btn_ir_Click(object sender, RoutedEventArgs e)
{
Window1 miwin = new Window1();
miwin.ShowDialog();
}
}
}



and this is my code of my other widow




namespace ClientesWPF
{
/// <summary>
/// Lógica de interacción para Window1.xaml
/// </summary>
public partial class Window1 : Window
{



public Window1( )
{
InitializeComponent();

}


private void Btn_buscar_Click(object sender, RoutedEventArgs e)
{


}


}
}


So, how can i do that? i need call that list on the window? i need create a new list? how can i do that, please help T-T

Continue reading...
 

Similar threads

Back
Top