More suffering with binding for over an hour now. I have a Window with an
editable ComboBox bound to a property which throws in the setter if the
value is missing. The XAML below is how I've defined the control. If I blank
the title out I get the correct behaviour in the UI where the throw causes
the binding to put a red box around the control.
However, when the Window opens and the Title is already missing, then no
validation has run and there is no initial red box. I've been trying to find
a way to force the validation to run when the Window opens without luck.
There are dozens of web articles on this problem and every bit of sample
code I can find has zilch effect at all (as expected!). A lot of pages tell
you to do this:
comboInstTitle.GetBindingExpression(ComboBox.TextProperty).UpdateSource();
But this does nothing. I've fiddled with lots of XAML properties and code
but it all does nothing.
How can I force the binding validation to run when a Window loads?
<ComboBox Grid.Row="0" Grid.Column="1" Width="350" IsEditable="True"
x:Name="comboInstTitle">
<ComboBox.Text>
<Binding Path=" Title" Mode="TwoWay" NotifyOnValidationError="True"
NotifyOnSourceUpdated="True">
<Binding.ValidationRules>
<ExceptionValidationRule ValidatesOnTargetUpdated="True"/>
</Binding.ValidationRules>
</Binding>
</ComboBox.Text>
</ComboBox>
Greg