.NET9 - Using a SelectionChanged EventToCommandBehavior with a BindingContext

Hola from Spain,

I have XAML page which is utilising an SfBottomSheet with an SfChipGroup (2 chips) and an Entry field + two buttons.

The SfChipGroup utilises an EventToCommandBehavior, as such:

<core:SfChip.Behaviors>
<toolkit:EventToCommandBehavior
EventName="SelectionChanged"
Command="{Binding Path=ChipSelectionChangedCommand}"
EventArgsConverter="{StaticResource GetUnitFromChip}"
BindingContext="{Binding Path=BindingContext, Source={x:Reference ChemicalsAddedChipGroup}, x:DataType=core:SfChipGroup}" />
</core:SfChip.Behaviors> Note that the BindingContext Source references the x:Name="ChemicalsAddedChipGroup" of the SfChipGroup
<core:SfChipGroup x:Name="ChemicalsAddedChipGroup" .............

Implementing this BindinContext causes an exception:  "An element with the name ChemicalsAddedChipGroup already exists in this NameScope"
Actually, using any x:Name="" causes the issue even without a BindingContext.

==> .NET9 Behaviors no longer automatically inherit the BindingContext of their parent

Is it possible for an SfBottomSheet to contain an SfChipGroup and have the SelectionChanged event propagated to my viewmodel Command with an EventToCommandBehavior?

Iain

1 Reply

VR Vallarasu Ravichandran Syncfusion Team November 4, 2025 12:01 PM UTC

Hi Iain Stirzaker,

Thank you for reaching out from Spain!

 

We understand you're encountering issues with the EventToCommandBehavior in your .NET 9 MAUI project, specifically when trying to bind the SelectionChanged event from an SfChipGroup inside an SfBottomSheet.

 

This behavior is due to a breaking change in .NET MAUI 9, where Behaviors no longer automatically inherit the BindingContext of their parent controls. This affects scenarios like yours, where the EventToCommandBehavior cannot resolve the command from the ViewModel unless the BindingContext is explicitly set.


As per your requirement, we’ve prepared a working sample and attached it for your reference. If we’ve misunderstood any part of your setup, please feel free to share more details, and we’ll be happy to adjust the solution accordingly.

 

Regards,
Vallarasu R.


Attachment: SfChipGroupSample_d00e5786.zip

Loader.
Up arrow icon