The amount of noise articles highlights one of WPF's biggest strengths and weaknesses; its flexibility. There's so many ways to solve problems in WPF it requires large amounts of experience to work out which is best. (This is why the learning curve is a backwards facing cliff).
While I think it's fantastic that the UI framework is so flexible, implementing the same approach in UI controls is not. In my opinion, the DataGrid attempts to do too much; it tries to cater for too many different display scenarios. While grids in other technologies have various degrees of success in pulling this off, in WPF it's not a good idea. Trying to marry a large, complicated, and flexible control like the DataGrid with a flexible UI framework like WPF produces too much complexity; I think it's virtually unmanageable. As I've said before, to tame the beast that is the DataGrid we've had great success extending it by putting boundaries around it's usage. We started out with making our grids read-only (with sorting and filtering) and added an optional total row. That gave us the insight we needed into how the DataGrid worked and the degree of insanity required to develop it. We then added controlled grouping, and recently branched out and added in-grid editing; again with many boundaries on usage. Fortunately I've only been acting as a high-level sounding board to the DataGrid work by our team and have so far avoided the substance abuse required to complete the task and remain relatively sane. However, we're now starting our move to Windows 7 64 bit, and the DataGrid is having major issues with the idea. As the WPF guru in the team, I'm going to have no choice but to jump in the ring and start swinging. Time to dust off the stubby holder and the adult diapers. See you on the other side Ray. Carl. [usual disclaimers apply] Carl Scarlett Senior .NET/WPF Developer, UX Designer | Genesis Enterprise Services | Bankwest A: Level 5, 199 Hay Street | Perth | Western Australia | 6004 P: (08) 9449 8989 M: 0408 913 870 E: [email protected] Description: Description: test From: [email protected] [mailto:[email protected]] On Behalf Of Greg Keogh <[email protected]> Sent: Tuesday, 6 March 2012 8:40 PM To: "'ozWPF'" <[email protected]> Subject: WPF DataGrid sorting Last week I asked if anyone knew how to detect when a DataGrid is sorted so that you can remember the column and direction, so you can restore them when the app starts again. It turns out this can be done, but not in the way I described the problem. There is no event in the DataGrid, DataView, DataTable or other bindable collection I can find that will tell you when a sort has been performed. You have to: trap the grid's Sorting <http://msdn.microsoft.com/en-us/library/system.windows.controls.datagri d.sorting.aspx> event identify the grid column (which might be a template) and its current direction (which is nullable) sort the data source yourself then set the column's SortDirection (to set the column header arrow) set e.Handled = true You get the column and direction in the event, so it's your responsibility to add a bit of plumbing to load and save a change of sort at a suitable time. I've done all this, and although it's not much total code, it took an irritating amount of time to get it dead-right. A lot of time was wasted searching through hundreds of utterly stupid, off-track or misleading web articles on the subject ... which I think is a growing problem these days as amount of "noise" articles is clogging search engines and wasting search time looking for rare "real" answers and advice. Greg ______________________________________________________________________ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com ______________________________________________________________________ _______________________________________________ ozwpf mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf ________________________________________________________________________ _______ This email has been scanned by the Bankwest Email Security System. ________________________________________________________________________ _______ _______________________________________________________________________________ Unencrypted electronic mail is not secure and may not be authentic. If you have any doubts as to the contents please telephone to confirm. This electronic transmission including any attachments is intended only for those to whom it is addressed. It may contain copyright material or information that is confidential, privileged or exempt from disclosure by law. Any claim to privilege is not waived or lost by reason of mistaken transmission of this information. If you are not the intended recipient you must not distribute or copy this transmission and should please notify the sender. Your costs for doing this will be reimbursed by the sender. We do not accept liability in connection with computer virus, data corruption, delay, interruption, unauthorised access or unauthorised amendment. _______________________________________________________________________________ ______________________________________________________________________ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com ______________________________________________________________________
<<inline: image001.png>>
_______________________________________________ ozwpf mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
