首次提交
This commit is contained in:
86
WpfAppTest/MainViewModel.cs
Normal file
86
WpfAppTest/MainViewModel.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace WpfAppTest
|
||||
{
|
||||
public partial class MainViewModel : ObservableValidator
|
||||
{
|
||||
[ObservableProperty]
|
||||
public partial string SampleText { get; set; }
|
||||
public MainViewModel()
|
||||
{
|
||||
SampleText = "TDC(1);800X800;\r\nYJ500x500;\r\nT7C25;B7C25;\r\nG10C20;\r\nA12@100/200(6);\r\n62.24;";
|
||||
}
|
||||
[ObservableProperty]
|
||||
[NotifyDataErrorInfo]
|
||||
[MinLength(1)]
|
||||
private double pileSpacing;
|
||||
|
||||
public object SelectedItem { get; set; }
|
||||
public List<Student> Students { get; } = new List<Student>
|
||||
{
|
||||
new Student("Alice", 20),
|
||||
new Student("Bob", 22),
|
||||
new Student("Charlie", 19),
|
||||
new Student("Diana", 21),
|
||||
new Student("Ethan", 23)
|
||||
};
|
||||
public List<Gender> Genders { get; set; } = new List<Gender> { Gender.Male, Gender.Female };
|
||||
|
||||
public List<string> Items { get; } = new List<string>
|
||||
{
|
||||
"Item 1",
|
||||
"Item 2",
|
||||
"Item 3",
|
||||
"Item 4",
|
||||
"Item 5"
|
||||
};
|
||||
|
||||
[RelayCommand]
|
||||
private void Confirm()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public enum Gender
|
||||
{
|
||||
Male,
|
||||
Female,
|
||||
}
|
||||
public class Student
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Age { get; set; }
|
||||
public int Birth { get; set; }
|
||||
|
||||
public int Month { get; set; }
|
||||
|
||||
public int Year { get; set; }
|
||||
|
||||
public int Day { get; set; }
|
||||
|
||||
public int MonthDay { get; set; }
|
||||
|
||||
public bool IsSelected { get; set; }
|
||||
|
||||
public Gender Gender { get; set; }
|
||||
|
||||
|
||||
public Student() { }
|
||||
public Student(string name, int age)
|
||||
{
|
||||
Name = name;
|
||||
Age = age;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Name}, {Age} years old";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user