/// <summary> /// Creates a new instance of <see cref="DataLoaderViewState"/> copying all propreties from the provided <paramref name="dataLoaderViewState"/>. /// </summary> /// <remarks> /// This copy constructor can be useful if you want to use x:Bind inside a DataLoader's ContentTemplate. /// </remarks> /// <param name="dataLoaderViewState">The copy reference.</param> public DataLoaderViewState(DataLoaderViewState dataLoaderViewState) { View = dataLoaderViewState.View; Parent = dataLoaderViewState.Parent; Source = dataLoaderViewState.Source; Request = dataLoaderViewState.Request; Data = dataLoaderViewState.Data; Error = dataLoaderViewState.Error; IsLoading = dataLoaderViewState.IsLoading; IsInitial = dataLoaderViewState.IsInitial; IsEmpty = dataLoaderViewState.IsEmpty; }
private void UpdateUI(IDataLoaderState newState) { var safeState = newState ?? DataLoaderState.Default; var view = Delegate.GetView(); var viewState = CreateDataLoaderViewState(safeState, view); Delegate.SetState(viewState); if (view != null) { var dataVisualState = GetDataVisualState(safeState); GoToState(view, DataVisualGroup, dataVisualState); var errorVisualState = GetErrorVisualState(safeState); GoToState(view, ErrorVisualGroup, errorVisualState); var loadingVisualState = GetLoadingStateVisualState(safeState); GoToState(view, LoadingVisualGroup, loadingVisualState); var combinedVisualState = $"{dataVisualState}_{errorVisualState}_{loadingVisualState}"; GoToState(view, CombinedVisualGroup, combinedVisualState); if (_isLoaded) { _isVisualStateRefreshRequired = false; if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation($"Updated VisualStates to '{combinedVisualState}'."); } } else { // If the control isn't loaded, the visual states are not applied. _isVisualStateRefreshRequired = true; if (_logger.IsEnabled(LogLevel.Debug)) { _logger.LogTrace($"Saved VisualStates to '{combinedVisualState}'. (This control isn't loaded yet.)"); } } } _lastUpdate = DateTime.Now; _lastState = safeState; _lastViewState = viewState; }
void IDataLoaderViewDelegate.SetState(DataLoaderViewState viewState) { SetState(viewState); }
/// <summary> /// Sets the <see cref="State"/>. /// </summary> /// <remarks> /// This method is virtual to allow creation of more strongly typed version of DataLoaderView to allow usage of x:Bind inside the ContentTemplate. /// </remarks> /// <param name="state">The <see cref="DataLoaderViewState"/> to set as the current state.</param> protected virtual void SetState(DataLoaderViewState state) { State = state; }