I have this template for an itemscontrol:
<DataTemplate DataType="{x:Type models:StringParameter}">
<TextBox materialDesign:HintAssist.Hint="{Binding Name}">
<TextBox.Text>
<Binding Path="Value">
<Binding.ValidationRules>
<ınteractiveCode:NotEmptyValidationRule ValidatesOnTargetUpdated="True"></ınteractiveCode:NotEmptyValidationRule>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</DataTemplate>
And I have a button that works with a command, I want it to get enabled when all validations are met in ItemsControl. But I can't find a way to reach textboxes which are inside data templates.
I have a simple approach to solve this specific issue. I have created a
ValidationCheckerclass that will check for existence of validation errors usingIsValidmethod.ValidationObjectattached property can be implemented as like belowYou have already mentioned that your
Buttonhas been bind to aCommand. So implementCanExecutemethod for theCommandand callValidationChecker.Isvalid(). Don't forget to invokeRaiseCanExecutemethod for thisCommandwhenever you need.