dotnet / dotnet/maui-samples

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

Open
#484 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

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.

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.