Building the ExtendedContentPage
Add a new folder called UI
inside the FileStorage
project, add in a new file called ExtendedContentPage.cs
, and implement the following:
public class ExtendedContentPage : ContentPage { #region Private Properties private ViewModelBase _model; #endregion #region Constructors public ExtendedContentPage(ViewModelBase model) { _model = model; _model.Alert -= HandleAlert; _model.Alert += HandleAlert; } #endregion #region Private Methods private async void HandleAlert(object sender, string message) { await DisplayAlert("FileStorage", message, "OK"); } #endregion }
The _model
property is used to reference the view-model of each page as every view-model inherits the ViewModelBase
class. When the page is created, we register the HandleAlert
function to the view-model Alert
event. Every time this function is called, it will call the DisplayAlert...