Catel.MVVM.ViewModelBase.InitializeViewModelAsync C# (CSharp) Method

InitializeViewModelAsync() public method

Initializes the view model. Normally the initialization is done in the constructor, but sometimes this must be delayed to a state where the associated UI element (user control, window, ...) is actually loaded. This method is called as soon as the associated UI element is loaded.
It's not recommended to implement the initialization of properties in this method. The initialization of properties should be done in the constructor. This method should be used to start the retrieval of data from a web service or something similar. During unit tests, it is recommended to manually call this method because there is no external container calling this method.
public InitializeViewModelAsync ( ) : Task
return Task
        public async Task InitializeViewModelAsync()
        {
            if (!_isViewModelInitialized)
            {
                _isViewModelInitialized = true;

                await InitializeAsync();

                Initialized.SafeInvoke(this);
                await InitializedAsync.SafeInvokeAsync(this);
            }
        }