Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViewModel reset prior to View disappearing #303

Open
munkii opened this issue Feb 10, 2020 · 2 comments
Open

ViewModel reset prior to View disappearing #303

munkii opened this issue Feb 10, 2020 · 2 comments

Comments

@munkii
Copy link

munkii commented Feb 10, 2020

When we call PopPageModel with animate=true the input controls on the View temporarily appear as zero.

For example if we bind a Entry to a double property

<Entry Text="{Binding TemperatureValue}"></Entry>

Then call

await this.CoreMethods.PopPageModel(newTemperature, true, true);

The text box resets to blank and that is visible for about 0.5 seconds before the View disappears. This is because the BindingContext gets set to Null prior to the View disappearing.

If I remove the binding in BindingContextChanged then the TextBox\Entry field continues to display data as I'd expect but I assume that isn't the expected approach.

protected override void OnBindingContextChanged()
{
    if (this.BindingContext == null)
    {
        this.txtTemperature.RemoveBinding(SfNumericTextBox.ValueProperty);
    }

    base.OnBindingContextChanged();
}

I assume this is By Design. Is there a suggested approach to prevent the momentary flash of an unbound View?

UPDATE
I have also asked this question StackOverflow, https://stackoverflow.com/questions/60171744/freshmvvm-and-resetting-vm-before-popping-modal

@nexxuno
Copy link

nexxuno commented Apr 9, 2020

I'm struggling with this problem too. It hurts badly in my scenario because I have property bound two way with a converter on it and the ConvertBack method gets called with null values and crashes. I could workaround this but then my viewmodel would receive a bad value to persist so that's not an option. @rid00z this looks like a big bug to go unnoticed for so long, what are we missing here?

@munkii
Copy link
Author

munkii commented Apr 9, 2020

@nexxuno I do think it is a bug and it's good to hear i'm not the only one. I'd love to get some input from @rid00z but in the meantime I have updated the stackoverflow question with the solution we have gone with, https://stackoverflow.com/questions/60171744/freshmvvm-and-resetting-vm-before-popping-modal/61118083#61118083

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants