Hi,
I have a question about cancelling a userinteraction on a XamComboEditor.
This is the scenario:The user selects a new value which is available in the list.The user gets a Dialog if he really want to make that change.If the user anwsers yes then I don't have to do a thing. The underlying property is set to the new value and everything is OK. If the user awnsers No then I won't set the underlying databinded property, but the combo shows me that the new value is the value the user selected before he said no. In other words the value property isn't in sync anymore with the selected item property.WHat am I doing wrong ?
Hello,
You can try the following code snippet, where chaged is a boolean variable. It is necessary, because if you choose to revert the value back to the old one, ValuChanged will fire again just for this - to update to the old one, so you need to cancel that second invocation:
void xamComboEditor1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
Debug.WriteLine("value changed");
if (changed)
changed = false;
return;
}
if (MessageBox.Show("Confirm?", "MS BOX", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes, MessageBoxOptions.DefaultDesktopOnly)
== MessageBoxResult.Yes)
xamComboEditor1.EndEditMode(true, true);
else
xamComboEditor1.EndEditMode(false, true);
changed = true;
Thanks for the response. In your solution the interception is to late. Because the underlying binded property is changed to the new value before the suggested code is hit. I don't want to set the value back to the old value but I want to avoid the change to the newvalue.
The event before ValueChanged is SelectedItemChanged, which you can use as well