Files
SZMCToolkit.RevitAddins/WpfAppTest/MainViewModel.cs
2026-02-23 10:28:26 +08:00

86 lines
2.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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";
}
}
}