开发者

WPF - custom data presentation

I would like, using WPF, to present data in the following form:

Image: http://i.stack.imgur.com/54CkI.png

Namely - the data grouped by month. The header row of each month, details and a summary row. Details in the form of a simple table with several columns.

In addition, when I was t开发者_运维知识库rying to group data by using CollectionViewSource.GroupDescriptions - it was very slow.

So I intend to group data in ViewModel and return them as a collection of objects of the class like that:

public class Group 
{ 
   string Month; 
   IEnumerable<GroupItem> Details; 
   string Summary; 
}

Columns do not have to be sorted, but it should be possible to change the width of columns globally - by all groups. I feel that the "game" will enter a sort of juggling with colspan and rowspan.

What's the best way to present such data in WPF - what controls to use, how to define a template.


I have used PivotGrid from DevExpress in windows forms applications and it is superb. I think they also do PivotGrid controls for Silverlight and WPF, you can check their web site.

I would not try to mimic all those features using standard controls, you would end up with so much coding and still a mediocre result compared to more solid and ad hoc developed components.

P.S. This is not spam, if you don't want to go DevExpress direction there are anyway many other vendors, I simply suggest what I know and what I know to be good and valid.


You could use a ListView and create an ItemTemplet.

Here is a basic skeleton. You may need to set some width and maybe add some borders to get the right result. You also need to create an ItemTemplate for the ListView showing the details.

<ListView ItemsSource="{Binding TheData}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Month}" />
                        <StackPanel>
                            <ListView ItemsSource="{Binding Details}" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </StackPanel>
                </Grid>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜