Issue: I have a list of a class that's being displayed in a Datagrid, one of the values needs to ask the user if they really want to change it. This was implemented with a YesNo MessageBox in the value's Setter.
The problem is that this messagebox should not come up every time the Setter is called, like when a new object is being added to the datagrid with a dialog, it will still ask if you are sure you want to change the value of what is currently being created.
I'm not sure if there's a clean way of doing this, so any help is appreciated.
Right now the setter in the class looks like this:
public string Value
{
get { return _value; }
set
{
string message = "Are you sure you want to modify this value?";
MessageBoxResult result = MessageBox.Show(message, "Confirmation",
MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
_value = value;
}
else
{
// Set to previously used value
Value = _value;
}
RaisePropertyChanged("Value");
}
}