SfButton uses wrong BindingContext inside of DataTemplate

I have the following code:


<syncfusion:SfListView ItemsSource="{Binding Aerodromes}">

<syncfusion:SfListView.ItemTemplate>

<DataTemplate x:DataType="{models:Aerodrome}">

<Label Text="{Binding Name}"/>

</DataTemplate>

</syncfusion:SfListView.ItemTemplate>

<syncfusion:SfListView.EndSwipeTemplate>

<DataTemplate x:DataType="{models:Aerodrome}">

<Grid>

<syncfusion:SfButton Command="{Binding BindingContext.EditAerodromeCommand, Source={x:Reference ThisAerodromesPage}}"
CommandParameter="{Binding }"/>

</Grid>

</DataTemplate>

</syncfusion:SfListView.EndSwipeTemplate>

</syncfusion:SfListView>


Inside the ItemTemplate, the BindingContext of the label is correctly set to the Aerodrome, however inside of the SwipeTemplate the SfButton incorrectly sets its BindingContext to the ViewModel of the page. This means instead of the Aerodrome being passed as the CommandParameter, the AerodromePageViewModel is passed instead. However if I use the standard MAUI button for example, the correct BindingContext is received.


1 Reply

KP Kamalesh Periyasamy Syncfusion Team March 4, 2024 02:12 PM UTC

Hi William,


After reviewing your query and the provided code snippet, we were unable to reproduce the reported issue at our end. Upon checking, we confirmed that the SfButton received the CommandParameter as the Aerodrome model properly and based on that we have prepared a sample and attached for your reference.


To better understand and assist with resolving the issue, we kindly request that you provide a sample demonstrating the problem along with detailed information and replication steps. Alternatively, please review the attached example and make any necessary modifications to reproduce the problem, and kindly forward it to us. This will enable us to conduct a more thorough investigation of the issue and provide you with an accurate solution.


Please review the attached sample and let us know if you have any further questions or concerns.


Regards,

Kamalesh P


Attachment: SfButtonSample_35ee0e20.zip

Loader.
Up arrow icon