Expander and DataGrid with c #, execute one event inside another

0

I expose my case, I have an Expander that starts closed, I expand it and with that I fill a DataGrid.

My problem:

When I click on a row in the DataGrid, I want the Expander to close, so I put in the event SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) the code Expander_Collapsed(null, null); so that the Collapsed event is executed and this executes the code that is in the event but does not actually execute the event because then the Expander does not work at all, and I am not able to convert the SelectedCellsChangedEventArgs in RoutedEventArgs so that the event work correctly.

Is there a method to convert one into another or what do I do to run the event correctly?

The code of Expander events:

private void Expander_Collapsed(object sender, RoutedEventArgs e) { 
GridBus.Visibility = Visibility.Hidden; 
}
private void Expander_Expanded(object sender, RoutedEventArgs e) {
 GridBus.Visibility = Visibility.Visible;
}

The code of the DataGrid event:

public void Seleccionar(object sender, SelectedCellsChangedEventArgs e){ 
Expander_Collapsed(null, null);
}

This works because only the code of the Expander_Collapsed is executed, not the event itself, that is, the inherent functionality that I do not program, I can instead put, Expander_Collapsed(null, null); put Expander_Collapsed(sender, e); but the e error, there is my question if it can be converted from one type to another or there is another way to carry out what I want to do.

Graphic explanation:

In step 2, (image 2) is when I click on a row

    
asked by Karveg 13.06.2018 в 19:16
source

0 answers