I have a DataGrid with records and an Edit button. At the moment I'm doing the following: the user selects the item from the DataGrid and clicks the Edit button, to then be checked whether or not it can edit the record. I would like to disable the button once the item was selected in the DataGrid, without having to click the button to then be warned that it can not edit.
private void btnEditar_Click(object sender, RoutedEventArgs e)
{
if (dataGrid.SelectedItem != null)
{
if (Presenter.PodeEditar())
{
chamaMetodoEdicao();
}
else
MessageBox.Show("Impossível editar!");
}
else
MessageBox.Show("Selecione um item.");
}