0

I have a data grid in my parent view.

When I select an item in the grid,

  1. I would like to open a child window

  2. and pass the selected item value to the child window

  3. I need to submit changes based on the selected value.

I'm revising the following code that is the click events that I need to transfer to the child window.

Can I inherit the domain datasource from the parent view?

    private void ApproveCmd_Click(object sender, RoutedEventArgs e)
    {
        PA_Request selReq =(PA_Request) this.onticPMA_RequestRadGridView.SelectedItem;
        if (selReq != null)
        {
            ((PA_Request)this.PA_RequestRadGridView.SelectedItem).STATUS = "Approved";

            this.PA_RequestDomainDataSource.SubmitChanges();



        }
    }

    private void DissaproveCmd_Click(object sender, RoutedEventArgs e)
    {
        PA_Request selReq = (PA_Request)this.PA_RequestRadGridView.SelectedItem;
        if (selReq != null)
        {
            ((PA_Request)this.PA_RequestRadGridView.SelectedItem).STATUS = "Disapproved";

            this.PA_RequestDomainDataSource.SubmitChanges();


        }
    }

    private void ApplyCmd_Click(object sender, RoutedEventArgs e)
    {
        PA_Request selReq = (PA_Request)this.PA_RequestRadGridView.SelectedItem;
        if (selReq != null)
        {
            ((PA_Request)this.PA_RequestRadGridView.SelectedItem).STATUS = "Applied";

            this.PA_RequestDomainDataSource.SubmitChanges();

        }
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
technette
  • 1
  • 3

1 Answers1

0

Ok suppose there are 10 elements in the grid. When you click on any of the item an event is opened say ApproveCmd_Click. You need to first retrieve sender like this.

private void ApproveCmd_Click(object sender, RoutedEventArgs e) 
{
  var senderListBox = sender as ListBox; (Or any type you want)
  var senderListBoxItem = senderListBox as senderListBoxItem;
  string data = senderListBoxItem.Content;
  //Now you have sender. 
  // Pass sender through constructor of the window
  //Say you need to pass a string Create 

  var chieldWindow = new ChieldWindow(data);
}

in chield window

class ChieldWindow :Window
{
   ChieldWindow(string input)
   {
      \\You got the data
   }
}

Lemme know

om471987
  • 5,398
  • 5
  • 32
  • 40