In my WPF application I have classes Student and StudentDB.
class StudentDB
{
int StudentId{get;set;}
string Name{get;set;}
string City{get;set;}
DateTimeOffset BirthDate{get;set;}
}
class Student
{
int StudentId{get;set;}
string Name{get;set;}
string City{get;set;}
DateTime BirthDate{get;set;}
}
The main difference between two classes is the datatype of the Birthday property. one is DateTime
and another one is DateTimeOffset
.
Im having following code in my application.
IEnumerable<StudentDB> StudentDbs = GetAllStudentFromDB();
IEnumerable<Student> Students = new IEnumerable<Student> Students();
XAML:
<DataGrid ItemsSource="{Binding Students, Mode=TwoWay}" AutoGenerateColumns="True">
I need to display the list of student in the DataGrid.
I cannot bind the StudentDbs since it has a DateTimeOffset
type property.
To solve above issue I need to apply a Value Converter
, which will convert StudentDb
object to Student
object.
I know how to implement IValueConverter interface I. But i don't know how to apply it for a collection.
Can anyone suggest me a solution to solve this?