如何为 Win8 App Store 构建我自己的 DataGrid? [英] How to build my own DataGrid for Win8 App Store?

查看:23
本文介绍了如何为 Win8 App Store 构建我自己的 DataGrid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目列表,我想在类似表格的控件中为我的 Win8 应用商店显示这些项目.假设对象 Item 包含条形码、价格和金额(都是双精度类型).我想为这个对象的每个道具呈现一个包含不同列的表格.我还想在 LayoutAwarePage 中显示此表.有任何想法吗?

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?

推荐答案

可以从这里开始:如何获取类似UI的数据网格项目的集合?

MyToolkit - DataGrid

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; }
}

这篇关于如何为 Win8 App Store 构建我自己的 DataGrid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆