Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

MultiValidationBehavior overwrites external BindingContext bindings #1153

@bakerhillpins

Description

@bakerhillpins

Description

MultiValidationBehavior doesn't respect bindings made on the BindingContext of children, it overwrites them. BaseBehavior<T> only applies a binding if one doesn't exist, while MultiValidationBehavior overwrites any existing binding.

Steps to Reproduce

This works:

 <Entry.Behaviors>
        <behaviors:TextValidationBehavior BindingContext="{Binding BindingContext.Range, Mode=OneWay, Source={x:Reference Entry}}"
                                          MaximumLength="{Binding Maximum, Mode=OneTime}"
                                          MinimumLength="{Binding Minimum, Mode=OneTime}"
                                          InvalidStyle="{StaticResource InvalidEntryStyle}" />
</Entry.Behaviors>

This doesn't:

  <Entry.Behaviors>
      <behaviors:MultiValidationBehavior>
          <behaviors:TextValidationBehavior BindingContext="{Binding BindingContext.Range, Mode=OneWay, Source={x:Reference Entry}}"
                                            MaximumLength="{Binding Maximum, Mode=OneTime}"
                                            MinimumLength="{Binding Minimum, Mode=OneTime}"
                                            InvalidStyle="{StaticResource InvalidEntryStyle}" />
      </behaviors:MultiValidationBehavior>
  </Entry.Behaviors>

Expected Behavior

The binding would be respected even though it's part of a Validation Collection.

Actual Behavior

The Binding to the ViewModel's Range property doesn't occur.

Basic Information

  • Version with issue: 1.1.0
  • Last known good version: None

All platforms.

Workaround

A workaround is to refactor the ViewModel so that all of the data needed for all of the ValidationBehaviors in the collection is bound to the MultiValidationBehavior with separate properties for each item of the collection.

Project

MultiValidationBug.zip

Metadata

Metadata

Labels

a/validationbugSomething isn't working. Breaky break.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions