Skip to content

Command bindings are not re-established when navigating back and forth in UIInterface samples #484

@TheKoren

Description

@TheKoren

Due to how the navigation stack is being managed the command bindings are not properly refreshed when navigating between views in UserInterface samples.

Expected Behavior

Navigation is possible between different Views without reloading the application.

Possible Solution

I've tried an approach where i reset the 'BindingContext' in the 'OnAppearing' method and it solves the problem.

Steps to Reproduce

  1. Open 'UserInterface\Layouts\StackLayoutDemos' solution.
  2. Run the application.
  3. Select the AlignmentPage demo.
  4. Navigate back to the MainPage using the back button.
  5. Try to select any of the demos available from MainPage UI. Nothing should happen in it's current form.

Possible Implementation

Adding this to the MainPage solves the problem.

protected override void OnAppearing()
{
    base.OnAppearing();
    BindingContext = null;
    BindingContext = this;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions