WPF Table View, a Lightweight Data Grid Built for Performance
Graham Knight is developing a lightweight, high performance data grid for WPF. This data grid, known as WPF Table View, is available on CodePlex under the Microsoft Public License.
InfoQ: What failings in WPF's data grid caused you to decide to build your own?
Performance was the main reason for not using the WPF data grid, I needed to be able to view 100,000+ rows of data with dynamically defined columns and column data templates, as soon as I threw this at the data grid the user experience began to suffer. I also tried some commercial grid controls as well and while they had better performance they ended up being too complicated and difficult to understand for my needs.
InfoQ: What is the philosophy of your data grid? Is it intended to be bare bones and extensible or are you looking to a rich feature set that should cover most use cases out of the box?
This is definitely a bare bones solution, I have no built-in support for different column types, no editing mode, no theme packs, these are features that can be reasonably easily added using some data templating so I didn't need to add them to the component.
So I have hopefully created a grid component that's simple enough for people to understand and has good performance when rendering data templated data. You will need to understand a bit about data binding and data templating to make full use of Table View but since that's fundamental to WPF anyone using the control should be able to handle that.
In the future I will probably enhance the feature set of the control but not at the expense of speed or basic simplicity of use.
InfoQ: 100,000 rows is a lot of information to offer the customer. Why did you need to show so much information at one time?
I am currently working in the financial industry and I have to render real-time profit and loss reports across large portfolios of stocks. TableView displays frequently changing data for each row of the report as stock prices change, in addition I have to calculate and render multi-level aggregations of the P&L data, this means that all the data is loaded in memory to keep the performance reasonable.
InfoQ: So what features did you feel were essential?
Performance and virtualization. My main requirement is to display data rather than to edit data, that's not to say that TableView can't be used to edit data you will just need to write the view models and data templates yourself to allow the data to be edited.
By keeping the TableView model simple means that there are few layers between the underlying data and the displayed data. Virtualization is used for performance reasons and also because of the large amount of data that I need to manage, TableView only creates row containers for the rows that will be displayed and re-cycles these contains as the user scrolls through the table. This significantly reduces the amount of memory and resources that the control uses.
This was also a great opportunity to learn about the ItemsControl and how lookless controls work.
InfoQ: Were you able to use something like a virtualizing stack panel or did you have to build your own from scratch?
I used the virtualizing stack panel, there was no reason to re-invent the wheel here, thankfully the excellent series of articles by Dr WPF on the ItemsControl, control templates and the lookless control model really helped to understand what was going on under the hood.
InfoQ: How much time did you invest in this project so far?
Probably only a month, but this was spread out over say six months as this was something I did in the background. Most of the time was spent researching how all the different aspects of creating a grid type control goes together and trying to study how the existing components worked such as the Listbox, ListView and Data Grid.
Tiago Romero Garcia Mar 01, 2015