0
I use a userControl
customized to show a Data Grid
and when I double-click some line, I call a registration window, which is waiting to send the ID
of the line selected as parameter, wanted to simplify by passing this method of all screens Data Grid
to the userControl
customized as virtual method, so in double click I would call only the method, only I cannot pass the window name as parameter.
Failed example of the userControl virtual method (in theory that would be)
public virtual void AbrirJanelaCadastro(Window window, DataGrid grid)
{
DataRow dataRow = (grid.SelectedItem as DataRowView).Row;
window(dataRow.Field<Int32>("ID")).ShowDialog();
}
Example of method call to open window in double click
private void grid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
AbrirJanelaCadastro(Cliente, Grid);
Explain why the code is "flawed". The question is not clear enough.
– Gabriel Faria