Item Changes
ItemChanging
Manipulate the behavior of the control before the change has taken place. This method can be found in wndProjektPainter (Shortcut: PP)
ItemChanging can return different values:
ItemChangingResult.Continue: validates the changing and continues
ItemChangingResult.Reject: does not reject the value, keeps the wrong one and does not continue until a valid value is given
ItemChangingResult.RejectAndContinue: reject the changes and continues; keeps the previous value of tha variable;
Best practice: use RejectAndContinue.
public override ItemChangingResult ItemChanging(UIElement container, FrameworkElement element, object selectedItem, object newValue, object oldValue)
{
if (element == tbTerminJahr)
{
var newJahr = newValue.ToInt(0);
if (newJahr < 1900 || newJahr > 2100)
{
LoggerSink.PushMessage(this, "Ungültiges Jahr", Severity.Warning);
return ItemChangingResult.Reject;
}
}
else if (element == tbTerminKW)
{
var newKw = newValue.ToInt(0);
if (newKw < 1 || newKw > 54)
{
LoggerSink.PushMessage(this, "Ungültige KW", Severity.Warning);
return ItemChangingResult.Reject;
}
}
return base.ItemChanging(container, element, selectedItem, newValue, oldValue);
}ItemChanged
Behavior after changing value of an control.
Since v16 ItemChanged took over the functionality of ItemSearched.
Best-practice: Group your code by selecting the container (DataPanel, DataGrid), followed by the control from the container (TextBox, DataGrid Column).
Example where in ItemChanged event we can access the searched row/rows via searchControl.ResultRow/ExtraRows:
Last updated