I am building a basic database application in WPF and I started using the MVVM pattern.
I have a dialog that asks the user to select an item from ListBoxand click OK. After that, I take the element that the user clicked on the object in the view model and passed it to another dialog box. But if the user clicks “Cancel”, I set this value to null, and the action is canceled: I do not open the next dialog box and do not return to the main screen. Example:
public class SelectEquipmentViewModel : WorkspaceViewModel
{
private bool _selected;
public Equipment SelectedEquipment
{
}
public void ExecuteSelect()
{
_selected = true;
RequestClose();
}
public override void RequestClose()
{
if (!_selected)
{
SelectedEquipment = null;
}
base.RequestClose();
}
}
, , "X" . RequestClose , null, .
Closing , , , .
"" ?
.
user153498