C#C
C#3y ago
2 replies
archie

❔ Binding method called multiple times

Hello, I'm new to MAUI.
I have face the following strange issue during development my app:

Project with a demonstration of the issue: https://github.com/archie1602/MauiTest

The application consists of two pages: MainPage and SettingsPage

On the SettingsPage:
I have a control witch Switch, which I binded to the SettingsViewModel via EventToCommandBehavior from CommunityToolkit.Maui.

When switching the toggle switch, the OnBroadcastingToggled method is started. It works fine. But:
If, for example, I return to the MainPage page and go back (again) to the SettingsPage, and then switch the slider again (switch), the method OnBroadcastingToggled will be called 2 times. If I do it 5 times, then he will be called 5 times and so on...

My question is why is it called multiple times instead of one?

P.S. if I remove the binding properties IsToggled="{Binding IsBroadTogl}", then this problem disappears. But it's weird... Maybe I'm doing the wrong binding? Or is there some kind of double binding going on?

Ref: https://github.com/archie1602/MauiTest/blob/master/SettingsPage.xaml

Thanks.
image.png
GitHub
Contribute to archie1602/MauiTest development by creating an account on GitHub.
GitHub - archie1602/MauiTest
GitHub
Contribute to archie1602/MauiTest development by creating an account on GitHub.
MauiTest/SettingsPage.xaml at master · archie1602/MauiTest
Was this page helpful?