Beispiel #1
0
        // This method runs just before the page appears - overriding allows for calling of
        //      methods upon page display, for example.
        protected override async void OnAppearing()
        {
            base.OnAppearing(); // Inherit from base method to avoid missing essential code

            // The object created within a using statement will last until the block within the using finishes executing,
            //      after which it will be disposed of. Thus, the object must implement the interface IDisposable.
            using (UserDialogs.Instance.Loading("Loading", null, "Cancel", true, MaskType.Clear))
            {
                // The following must be awaited, else the line after it will execute before it finishes running.
                await vm.CallApi();
            }

            //// This is an alternative to the above block. ShowLoading() cannot be used within a using statement, because
            ////      it does not implement IDisposable.
            //UserDialogs.Instance.ShowLoading("Loading employee listing...", MaskType.Black);
            //await vm.CallApi();
            //UserDialogs.Instance.HideLoading();

            // This line of code gives context for the binding that will happen in the xaml file.
            // The source is bound to the target.
            // Here, the vm is bound to the view, so the vm is the source, and the view is the target.
            this.BindingContext = vm;
        }