-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1164 from PrismLibrary/TabbedPage-NavigationPage-…
…IActiveAware added support for ActiveAware NavPages in a TabbedPage
- Loading branch information
Showing
9 changed files
with
98 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Source/Xamarin/Prism.Forms/Behaviors/NavigationPageActiveAwareBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Prism.Common; | ||
using Xamarin.Forms; | ||
|
||
namespace Prism.Behaviors | ||
{ | ||
public class NavigationPageActiveAwareBehavior : BehaviorBase<NavigationPage> | ||
{ | ||
protected override void OnAttachedTo(NavigationPage bindable) | ||
{ | ||
bindable.PropertyChanging += NavigationPage_PropertyChanging; | ||
bindable.PropertyChanged += NavigationPage_PropertyChanged; | ||
base.OnAttachedTo(bindable); | ||
} | ||
|
||
protected override void OnDetachingFrom(NavigationPage bindable) | ||
{ | ||
bindable.PropertyChanging -= NavigationPage_PropertyChanging; | ||
bindable.PropertyChanged -= NavigationPage_PropertyChanged; | ||
base.OnDetachingFrom(bindable); | ||
} | ||
|
||
private void NavigationPage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName == "CurrentPage") | ||
{ | ||
PageUtilities.InvokeViewAndViewModelAction<IActiveAware>(AssociatedObject.CurrentPage, (obj) => obj.IsActive = true); | ||
} | ||
} | ||
|
||
private void NavigationPage_PropertyChanging(object sender, PropertyChangingEventArgs e) | ||
{ | ||
if (e.PropertyName == "CurrentPage") | ||
{ | ||
PageUtilities.InvokeViewAndViewModelAction<IActiveAware>(AssociatedObject.CurrentPage, (obj) => obj.IsActive = false); | ||
} | ||
} | ||
} | ||
} |