public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values == null) { throw new ArgumentNullException(nameof(values)); } IStepper stepper = values[0] as IStepper; FrameworkElement element = values[1] as FrameworkElement; StepperStepViewModel stepViewModel = values[2] as StepperStepViewModel; return(_iconTemplateSelector.SelectTemplate(stepper, element, stepViewModel)); }
/// <summary> /// Goes to the specified <see cref="StepperStepViewModel"/>. /// Throws an <see cref="ArgumentNullException"/> if stepViewModel is null. /// </summary> /// <param name="stepViewModel"></param> public void GotoStep(StepperStepViewModel stepViewModel) { if (stepViewModel == null) { throw new ArgumentNullException(nameof(stepViewModel) + " must not be null"); } // set all steps inactive except the next one to show foreach (StepperStepViewModel stepViewModelItem in _stepViewModels) { stepViewModelItem.IsActive = stepViewModelItem == stepViewModel; } OnPropertyChanged(nameof(ActiveStepViewModel)); OnPropertyChanged(nameof(ActiveStep)); OnPropertyChanged(nameof(ActiveStepContent)); }
private void StepSelectedHandler(StepperStepViewModel stepperStepViewModel) { if (!IsLinear) { StepperNavigationEventArgs navigationArgs = new StepperNavigationEventArgs(StepNavigationEvent, this, Controller.ActiveStep, stepperStepViewModel.Step, false); RaiseEvent(navigationArgs); if (StepNavigationCommand != null && StepNavigationCommand.CanExecute(navigationArgs)) { StepNavigationCommand.Execute(navigationArgs); } if (!navigationArgs.Cancel) { Controller.GotoStep(stepperStepViewModel); } } }
/// <summary> /// Initialises the steps which will be shown inside the <see cref="Controls.Stepper"/>. /// Throws an <see cref="ArgumentNullException"/> if any of the steps is null. /// </summary> /// <param name="steps"></param> public void InitSteps(IStep[] steps) { m_observableStepViewModels.Clear(); if (steps != null) { m_stepViewModels = new StepperStepViewModel[steps.Length]; for (int i = 0; i < steps.Length; i++) { IStep step = steps[i]; if (step == null) { throw new ArgumentNullException("null is not a valid step"); } m_stepViewModels[i] = new StepperStepViewModel() { Controller = this, Step = step, IsActive = false, Number = (i + 1), NeedsSpacer = i < (steps.Length - 1), IsFirstStep = i == 0, IsLastStep = i == (steps.Length - 1) }; m_observableStepViewModels.Add(m_stepViewModels[i]); } if (m_stepViewModels.Length > 0) { m_stepViewModels[0].IsActive = true; } OnPropertyChanged(nameof(Steps)); OnPropertyChanged(nameof(InternalSteps)); OnPropertyChanged(nameof(ActiveStepViewModel)); OnPropertyChanged(nameof(ActiveStep)); OnPropertyChanged(nameof(ActiveStepContent)); } }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { FrameworkElement element = container as FrameworkElement; StepperStepViewModel step = item as StepperStepViewModel; if (element != null && step != null) { if (step.IsFirstStep) { return(element.FindResource("firstHorizontalStepHeaderTemplate") as DataTemplate); } else if (step.IsLastStep) { return(element.FindResource("lastHorizontalStepHeaderTemplate") as DataTemplate); } else { return(element.FindResource("intermediateHorizontalStepHeaderTemplate") as DataTemplate); } } return(null); }
private void SelectStep(IStep step) { if (step != null && step != Controller.ActiveStep && !IsLinear) { bool isValid = ValidateActiveStep(); StepperStepViewModel activeStepViewModel = Controller.ActiveStepViewModel; StepperStepViewModel nextStepViewModel = Controller.InternalSteps.FirstOrDefault(stepViewModel => stepViewModel.Step == step); if (BlockNavigationOnValidationErrors && !isValid && (nextStepViewModel == null || nextStepViewModel.Number > activeStepViewModel.Number)) { RaiseNavigationCanceledByValidation(); return; } StepperNavigationEventArgs navigationArgs = new StepperNavigationEventArgs(StepNavigationEvent, this, Controller.ActiveStep, step, false); RaiseEvent(navigationArgs); if (StepNavigationCommand != null && StepNavigationCommand.CanExecute(navigationArgs)) { StepNavigationCommand.Execute(navigationArgs); } if (!navigationArgs.Cancel) { Controller.GotoStep(step); } else { // refresh the property with the old state ActiveStep = Controller.ActiveStep; } } }