Open sprotty opened 10 months ago
Hi,
We can reproduce the issue. Thank you for your sample code. The problem is that all the bindings are evaluated when the XAML is read at the startup. So switching pages do not refresh the bindings.
Here's a workaround: Define your own Wizard and override the OnCurrentPageChanged to clear the binding errors and update the binding source:
`public class MyWizard : Wizard { protected override void OnCurrentPageChanged( WizardPage oldValue, WizardPage newValue ) { if( ( newValue != null ) && newValue.Content is FrameworkElement element ) { for( var i = 0; i < VisualTreeHelper.GetChildrenCount( element ); i++ ) { var childVisual = VisualTreeHelper.GetChild( element, i );
var localPropertyValues = childVisual.GetLocalValueEnumerator();
while( localPropertyValues.MoveNext() )
{
if( localPropertyValues.Current.Value is BindingExpression bindingExpression )
{
if( bindingExpression.HasError )
{
Validation.ClearInvalid( bindingExpression );
bindingExpression.UpdateSource();
}
}
}
}
}
base.OnCurrentPageChanged( oldValue, newValue );
} }`
We will try to add this kind of fix for release v4.7. Thanks
Validation is done correctly on the first page of a wizard the first time it is displayed. If you then go to the next page no validation is displayed on any of the following pages, also if you go back to the first page, it does not re-do the validation.
XAML
Code behind
After re-visiting the page