Files
HandyControl/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs
T

52 lines
1.1 KiB
C#

using System.Linq;
using System.Windows.Controls;
using GalaSoft.MvvmLight.Command;
using HandyControl.Controls;
using HandyControlDemo.Data;
using HandyControlDemo.Service;
namespace HandyControlDemo.ViewModel;
public class StepBarDemoViewModel : DemoViewModelBase<StepBarDemoModel>
{
public StepBarDemoViewModel(DataService dataService) => DataList = dataService.GetStepBarDemoDataList();
private int _stepIndex;
public int StepIndex
{
get => _stepIndex;
#if NET40
set => Set(nameof(StepIndex), ref _stepIndex, value);
#else
set => Set(ref _stepIndex, value);
#endif
}
/// <summary>
/// 下一步
/// </summary>
public RelayCommand<Panel> NextCmd => new(Next);
/// <summary>
/// 上一步
/// </summary>
public RelayCommand<Panel> PrevCmd => new(Prev);
private void Next(Panel panel)
{
foreach (var stepBar in panel.Children.OfType<StepBar>())
{
stepBar.Next();
}
}
private void Prev(Panel panel)
{
foreach (var stepBar in panel.Children.OfType<StepBar>())
{
stepBar.Prev();
}
}
}