How to build my own DataGrid for Win8 App Store?

白昼怎懂夜的黑 提交于 2020-01-06 08:46:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!