WPF - exampe of GridView to Display a Tabular Data

WPF - Example on DataGrid to display a Tabular data. Where we have Display the Tabular data with DtaGrid, however, the WPF system has offered us some new features to display data in list view with GridView view model. 


As it has been said on MSDN - GridView Overview

GridView view mode is one of the view modes for a ListView control. The GridView class and its supporting classes enable you and your users to view item collections in a table that typically uses buttons as interactive column headers. This topic introduces the GridView class and outlines its use.

So to display the same data this time with ListView but with GridView viewmodel, you can write xaml as such .

<ListView ItemsSource="{Binding RiskData}"
                      >
                <ListView.View>
                    <GridView
                        AllowsColumnReorder="True"
                        ColumnHeaderToolTip="Sample Data Infomration">
                        <GridViewColumn 
                            DisplayMemberBinding="{Binding Book}"
                            Header="Book"
                            Width="Auto"
                            />
                        <GridViewColumn
                            DisplayMemberBinding="{Binding TradeType}"
                            Width="Auto"
                            >
                            <GridViewColumnHeader>Trade Type</GridViewColumnHeader>
                        </GridViewColumn>
                        <GridViewColumn
                            Header="Sector"
                            Width="Auto"
                            DisplayMemberBinding="{Binding Sector}"
                            >
                        </GridViewColumn>
                        <GridViewColumn
                            Header="RiskType"
                            Width="Auto"
                            DisplayMemberBinding="{Binding RiskType}"
                            />
                        <GridViewColumn
                            Header="Ccy"
                            DisplayMemberBinding="{Binding Ccy}"
                            Width="Auto">
                            
                        </GridViewColumn>
                        <GridViewColumn
                            Header="Tenure"
                            DisplayMemberBinding="{Binding Tenure}"
                            Width="Auto" />
                        <GridViewColumn
                            Header="PnlValue"
                            DisplayMemberBinding="{Binding PnlValue}"
                            Width="AUto" />
                        <GridViewColumn
                            Header="RiskValue"
                            Width="Auto"
                            DisplayMemberBinding="{Binding RiskValue}" />
                    </GridView>
                </ListView.View>
            </ListView>

The ListView due ot its lightweight is much faster in terms of performance. 

References

GridView Overview


转载于:https://my.oschina.net/u/854138/blog/137044

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值