我正在执行此XAML:
<StackPanel Margin="320,0,0,0" Grid.RowSpan="2">
<ListView ItemsSource="{Binding employeeCollection}">
<ListView.View>
<GridView>
<GridViewColumn Header="Employee ID" DisplayMemberBinding="{Binding Path=EmployeeID}"/>
<GridViewColumn Header="First Name" DisplayMemberBinding="{Binding Path=FirstName}"/>
<GridViewColumn Header="Last Name" DisplayMemberBinding="{Binding Path=LastName}"/>
<GridViewColumn Header="start" DisplayMemberBinding="{Binding Path=startHR}"/>
<GridViewColumn Header="finish" DisplayMemberBinding="{Binding Path=finishHR}">
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</StackPanel>
后面的代码是:
class employeesGrid //: INotifyPropertyChanged
{
ObservableCollection<employiesData> _employeeCollection =
new ObservableCollection<employiesData>();
public employeesGrid()
{
_employeeCollection.Add(new employiesData{
EmployeeID = "World Of Warcraft",
FirstName = "Blizzard",
LastName = "Blizzard",
startHR = "2222",
finishHR = "dfs"
});
}
public ObservableCollection<employiesData> employeeCollection
{ get { return _employeeCollection; } }
}
public class employiesData
{
public string EmployeeID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string startHR { get; set; }
public string finishHR { get; set; }
}
}
在我的主窗口里我在做什么:
/ /构造函数:
初始化组件();
employeesgrid em=新employeesgrid();
1.有人能告诉我我做错了什么吗?
2.InotifyPropertiesChanged为什么要使用它?我应该如何使用它?
感谢你关注我的工作,这对我来说意义重大:)
假设我在我的程序中需要两个这样的结构,那么最好的实现是什么?????