1using Microsoft.Maui.Controls.PlatformConfiguration;
2using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
18 set => this.BindingContext = value;
19 get => this.ViewModel<BaseViewModel>();
27 if (this.BindingContext is T ViewModel)
30 throw new ArgumentException(
"Wrong view model type: " + typeof(T).FullName);
45 this.On<iOS>().SetUseSafeArea(
true);
46 this.SetBackgroundColor();
47 Microsoft.Maui.Controls.Application.Current!.RequestedThemeChanged += this.OnRequestedThemeChanged;
50 this.Loaded += this.BaseContentPage_Loaded;
53 private void OnRequestedThemeChanged(
object? sender, AppThemeChangedEventArgs e)
56 this.SetBackgroundColor();
59 private void SetBackgroundColor()
64 private void BaseContentPage_Loaded(
object? sender, EventArgs e)
110 if (BeforeAppearing is not
null)
114 await BeforeAppearing(
this, EventArgs.Empty);
132 ViewModel.GetType().FullName ??
string.Empty, this.GetType().FullName ??
string.Empty];
148 string Message =
ServiceRef.
Localizer[nameof(AppResources.FailedToRestoreViewModelStateForPage),
149 ViewModel.GetType().FullName ??
string.Empty, this.GetType().FullName ??
string.Empty];
158 if (AfterAppearing is not
null)
162 await AfterAppearing(
this, EventArgs.Empty);
188 base.OnDisappearing();
216 ViewModel.GetType().FullName ??
string.Empty, this.GetType().FullName ??
string.Empty];
220 msg + Environment.NewLine + ex.Message);
234 ViewModel.GetType().FullName ??
string.Empty, this.GetType().FullName ??
string.Empty];
238 msg + Environment.NewLine + ex.Message);
261 MainThread.BeginInvokeOnMainThread(async () =>
263 if (ViewModel is not
null)
274 return base.OnBackButtonPressed();
303 if (this.Parent is
null)
306 await LifeCycleView.DoDispose();
311 await LifeCycleView.DoInitialize();
Base class that references services in the app.
static ILogService LogService
Log service.
static IUiService UiService
Service serializing and managing UI-related tasks.
static IStringLocalizer Localizer
Localization service
static ISettingsService SettingsService
Settings service.
Static class that gives access to app-specific themed colors
static Color PrimaryBackground
Primary background color.
virtual async Task OnAppearingAsync()
Asynchronous OnAppearing-method.
virtual bool OnToolbarBackButtonPressed()
A method which is called when the user presses the back button in the application toolbar at the top ...
EventHandlerAsync? OnAfterAppearing
Event raised after page appears
sealed override async void OnAppearing()
virtual void OnLoaded()
Method called when page has been loaded.
sealed override async void OnParentSet()
Called when the Page's Element.Parent property has changed.
T ViewModel< T >()
Convenience function for accessing the BindableObject.BindingContext property as a view model.
virtual async Task OnDisappearingAsync()
Asynchronous OnAppearing-method.
virtual ? string UniqueId
Gets or sets a unique identifier, which allows this page to be distinguished from other pages of the ...
sealed override bool OnBackButtonPressed()
Overrides the back button behavior to handle navigation internally instead.
sealed override async void OnDisappearing()
EventHandlerAsync? OnBeforeAppearing
Event raised before page appears
BaseViewModel ContentPageModel
Convenience property for accessing the BindableObject.BindingContext property as a view model.
BaseContentPage()
Creates an instance of the BaseContentPage class.
A base class for all view models, inheriting from the BindableObject. NOTE: using this class requir...
virtual async Task DoAppearing()
Method called when view is appearing on the screen.
bool IsAppearing
Returns true if the view model is shown.
virtual async Task GoBack()
Method called when user wants to navigate to the previous screen.
async Task DoDisappearing()
Method called when view is disappearing from the screen.
async Task SaveState()
Called by the parent page when it disappears on screen, before the DoDisappearing method is called.
async Task RestoreState()
Called by the parent page when it appears on screen, after the DoAppearing method is called.
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static Exception UnnestException(Exception Exception)
Unnests an exception, to extract the relevant inner exception.
Interface for views who need to react to life-cycle events.
delegate Task EventHandlerAsync(object Sender, EventArgs e)
Asynchronous version of EventArgs.