I want to use ValidationRules
to verify that a few ListBox
controls have at least one item selected.
I tried doing it this way:
<ListBox ItemsSource="{Binding Path=AvailableItems}"
Behaviors:MultiSelectorBehaviours.SynchronizedSelectedItems="{Binding ChosenItems}"
x:Name="ListBoxItems">
<ListBox.Tag>
<Binding ElementName="ListBoxItems" Path="SelectedItem">
<Binding.ValidationRules>
<ValidationRules:NotNullValidationRule />
</Binding.ValidationRules>
</Binding>
</ListBox.Tag>
</ListBox>
But my NotNullValidationRule
never gets called. Note that the SynchronizedSelectedItems
is a special attached property I use to synchronize the SelectedItems
to a custom collection (described here). That's why I do my validation on a 'fake' Binding
applied to Tag
instead.
Is there a way to validate ListBox.SelectedItems
?