问题
I have a list of items that I want to display in a table-like control, for my Win8 app store. Lets say that the object Item contains a Barcode, price and amount (all are double types). I want to present a table with different columns for each prop of this object. I would also like to present this table in a LayoutAwarePage. Any Ideas?
回答1:
You can start from here : How to get a data grid like UI for a collection of Items?
MyToolkit - DataGrid
Usage of MyToolkit DataGrid
<controls:DataGrid x:Name="dg">
<controls:DataGrid.Columns>
<controls:DataGridTextColumn Width="200" Binding="{Binding FirstName}" />
<controls:DataGridTextColumn Width="200" Binding="{Binding LastName}" />
</controls:DataGrid.Columns>
</controls:DataGrid>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ObservableCollection<viewModel> People = new ObservableCollection<viewModel>
{
new viewModel("fname", "lname"),
new viewModel("fname", "lname"),
new viewModel("fname", "lname"),
new viewModel("fname", "lname")
};
dg.ItemsSource = People;
}
public class viewModel
{
public viewModel(string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
}
public string FirstName { get; set; }
public string LastName { get; set; }
}
来源:https://stackoverflow.com/questions/18321276/how-to-build-my-own-datagrid-for-win8-app-store