C# .NET - passing parameter values from one class to other class

Asked By malatesh swadi on 01-May-12 01:56 AM
i am new user to wpf and i am using c# langue, i have to form1.xaml & form2.xaml and for them form1.xaml.cs  and form2.xaml.cs now i need to pass the values from form1.xaml.cs to form2.xaml.cs

can anybody help me 
S K replied to malatesh swadi on 01-May-12 02:07 AM
See this thread show with example how can pass value from one xaml page to another in wpf

hope this helps you
Neha Garg replied to malatesh swadi on 01-May-12 02:08 AM

Suppose you have a Employee object. Employee has number of Address. if you want to show employee on a  grid with Button(Window1.xaml), if user will press the button, other form (EmpAddress.xaml) will open with Address data of selected employee.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WPF_LINQ_New
  /// <summary>
  /// Interaction logic for Window1.xaml
  /// </summary>
  public partial class Window1 : Window
    public Window1()
    private void Button_Click(object sender, RoutedEventArgs e)
      Employee e1 = new Employee();
      EmployeeListBox.DataContext = e1.GetEmployees();
    private void Button_Click_1(object sender, RoutedEventArgs e)
      Employee e1 = ((Button)sender).DataContext as Employee;
      EmpAddress em = new EmpAddress();
      em.Addresses = new ObservableCollection<Contact>(e1.Addresses);
Neha Garg replied to malatesh swadi on 01-May-12 02:16 AM

See the below example also:
public partial class Page2 : UserControl
    App app = null;
    public Page2()
      app = (App)Application.Current;
      LabelDisplay.Text = LabelDisplay.Text + " " + app.Name;
    private void Button1_Click(object sender, RoutedEventArgs e)
      App.Navigate(new Page());
dipa ahuja replied to malatesh swadi on 01-May-12 03:29 AM
To pass data from one form to another form just write this way:

Form2 f1 = new Form2();
f1.textBox1.Text = "hello";