我這樣做XAML:WPF如何綁定gridview?
<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; }
}
}
在我的主窗口中我在做什麼:
//構造函數: InitializeComponent(); employeesGrid em = new employeesGrid();
1.can有人請指導我我做錯了什麼? 2.INotifyPropertyChanged我爲什麼要使用它?我應該如何使用它?
thanku對我的工作凝視它意味着很多我:)
可以說,我想要兩個sturctures像這樣在我的計劃什麼是最好的implmantion ????
我媒體鏈接發現soultion thanku – 2010-08-21 22:22:09