private void OnItemSourceChanged(Wizard wizard, AvaloniaPropertyChangedEventArgs e) { if (Items == null) { Items = new AvaloniaList <WizardPage>(); } if (e.NewValue == null) { return; } var list = e.NewValue as IEnumerable <IWizardPageVM>; if (list != null) { foreach (IWizardPageVM wizardPageVM in list) { IWizardPageVM vm = wizardPageVM as IWizardPageVM; WizardPage wizardPage = new WizardPage(); wizardPage.DataContext = vm; wizardPage.CanCancel = CanCancel; (this.Items as AvaloniaList <WizardPage>).Add(wizardPage); } } }
private void WizardPage_DataContextChanged(object sender, EventArgs e) { if (this.DataContext is IWizardPageVM) { IWizardPageVM wizardPageVM = this.DataContext as IWizardPageVM; Title = wizardPageVM.Title; Description = wizardPageVM.Description; PageType = wizardPageVM.PageType; } }
private void OnCurrentWizardPageVM(Wizard o, AvaloniaPropertyChangedEventArgs e) { if (e.NewValue == null) { return; } IWizardPageVM wizardPageVM = e.NewValue as IWizardPageVM; CurrentPage = this.Items.OfType <WizardPage>().FirstOrDefault(x => x.DataContext == wizardPageVM); }
private void ExecutePreviousPageCommand() { IWizardPageVM previousPage = null; var currentIndex = WizardPages.IndexOf(CurrentPage); var previousPageIndex = currentIndex - 1; if (previousPageIndex >= 0 && previousPageIndex < WizardPages.Count) { previousPage = WizardPages[previousPageIndex]; } CurrentPage = previousPage; UpdatePageCommand(); }
private void ExecuteNextPageCommand() { IWizardPageVM nextPage = null; var currentIndex = WizardPages.IndexOf(CurrentPage); var nextPageIndex = currentIndex + 1; if (nextPageIndex < WizardPages.Count) { nextPage = WizardPages[nextPageIndex]; } CurrentPage = nextPage; UpdatePageCommand(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(AvaloniaProperty.UnsetValue); } var list = value as IEnumerable <IWizardPageVM>; var result = new AvaloniaList <WizardPage>(); foreach (IWizardPageVM wizardPageVM in list) { IWizardPageVM vm = wizardPageVM as IWizardPageVM; WizardPage wizardPage = new WizardPage(); wizardPage.DataContext = vm; result.Add(wizardPage); } return(result); }