I'm building an app in Xamarin.Forms in which I want to use a Stepper. I'm using MVVM so I bind the value of the stepper to a value in my model. The stepper is in a (self build) collapsable listview. When a cell is decollapsed it will show the stepper. At the moment the stepper is shown on screen, the "Set" function of the binded property is called. I don't understand why. Shouldn't it call the "Get" function if it wanted to know the current value? Fun fact is that when the corresponding property is "0", the "Set" function is not called when the Stepper is shown on screen. When loading a label the "Get" function is nicely called.
Why is this and how can I solve the problem that I want to call a function to update a database via an api when the stepper is clicked/value is changed? I want to do it the MVVM way, of course I can do it in the code behind but I don't prefer that.
I currently use a different property for the stepper then the actual property with the value, as the value is set in different ways(also when loading from the API) and I don't want the loop that I load something and it updates the value immediately. I tried with the same property as well, but the same problem persists.
XAML
<Stepper x:Name="PredictionStepper" Minimum="0" Increment="1" Value="{Binding PredictionStepper}" IsVisible="{Binding PredictionCanBeAltered}" />
Model
public int PredictionStepper
{
get
{
return Prediction;
}
set
{
Prediction = value;
UpdateManager.Instance().Add(this);
}
}
public int Prediction
{
get
{
return Prediction;
}
set
{
Prediction = value;
OnPropertyChanged("Prediction");
}
}