개체 목록이 있고 WPF에서 '이전'및 '다음'단추를 사용하여 개체의 속성을 반복하고 싶습니다.
예를 들어 객체의 속성을 반복 할 때 '이전'버튼을 클릭하면 객체 앞에있는 객체의 속성이 'next'버튼을 통해 반복되고 있습니다.목록의 개체 속성을 반복하는 방법은 무엇입니까?
학생 목록에 studentList에 저장된 학생 개체의 성과 이름 및 수를 포함하는 학생 클래스가 있다면 어떻게해야합니까?
내가
class Student
{
private string firstName;
public string FirstName
{
get { return firstName; }
set { firstName = value; }
}
private string lastName;
public string LastName
{
get { return lastName; }
set { lastName = value; }
}
private string city;
public string City
{
get { return city; }
set { city = value; }
}
}
private void btnCreateStudent_Click(object sender, RoutedEventArgs e)
{
Student student1 = new Student();
student1.FirstName = txtFirstName.Text;
student1.LastName = txtLastName.Text;
student1.City = txtCity.Text;
studentList.Add(student1);
MessageBox.Show("Student Created");
txtFirstName.Clear();
txtLastName.Clear();
txtCity.Clear();
}
private void btnPrevious_Click(object sender, RoutedEventArgs e)
{
// need implementation code
}
private void btnNext_Click(object sender, RoutedEventArgs e)
{
// need implementation code
}
덕분에 당신이 어떤 바인딩 재료를 사용하지 않는 가정
이러한 유형의 질문은 더 많은 코드와 덜 추상적 인 설명으로 더 잘 작동합니다. –
질문에는 질문을 읽는 것으로 가정 할 수있는 기본 코딩이 포함되어 있습니다 ... '다음'및 '이전'버튼의 click 이벤트에 대한 eventHandler 메소드가 필요합니다. –
두 버튼의 Click 이벤트에 대한 이벤트 핸들러 메소드에는 다음이 포함됩니다 해결해야 할 문제를 상상할 수있는 기본 코딩. –