A Quick Look at Silverlight 2's DataGrid Control
If you follow my blog, you have probably noticed my obsession with data grids. I haven't actually checked my archives, but if I had to guess I would bet somewhere around 70% of all my posts in some way include ASP.NET's Repeater, GridView or ListView controls. Lately I have been taking a look at Silverlight 2 so naturally I was curious when I saw Scott Morrision's post titled Using the Silverlight DataGrid.
I eagerly read through his post and started working on creating a very basic demo app. I thought a good way to introduce myself to the DataGrid would be to build a page that allows me to set the values of the DataGrid properties so I could watch how it effects how the DataGrid presentation (usually this is what a designer is for, but it wasn't working so well for me. I am sure it's user error.). Anyway, I found this little app useful so I figured I would post the demo and source.
Also, just in case you haven't seen - the Silverlight DataGrid supports column resizing and freezing column/row headers! If you play around with the demo page you can see how this looks.
That's it. Enjoy!
Comments
http://codebetter.com/blogs/david.hayden/archive/2008/03/23/orlando-code-camp-rocked-wcsf-and-data-access-tips-and-techniques-presentations.aspx
Recognize anything on this page.. What better way to say you ROCK! than to use your stuff.
Stephen
Posted by: Stephen Patten | March 23, 2008 11:26 PM
Just wanted to tell how much i interest and learn from your examples, the most thing made you different, is the live examples :)
thanks.
Posted by: amr elgarhy | March 24, 2008 04:28 AM
Hi,
yes it looks good! I have just encountered small bug which might be just in my PC. When I click Opacity the screen changes to blank?
Also does this grid has the sorting ability?
Posted by: ajaxus | March 24, 2008 08:21 AM
Thanks for the example, Matt! Have you figured out how to implement Sorting in the DataGrid? I can't seem to get access to the Click event for the header ala WPF... is there another approach for SL2?
Posted by: Ethan Nagel | March 24, 2008 01:34 PM
@Stepehn -
Yep - I sure do. And it looks great.
@Amr -
Yea, I wish more bloggers would do this. Code snippets are great, but I like being able to watch it live.
@ajaxus -
I haven't had a problem with the opacity on either of my PC's (XP with IE7 or Vista with IE7). Anyone else seeing this?
@ajaxus, Ethan -
I haven't figured that out yet, but it is on my short list. I will write up a quick post once I get it figured out.
Posted by: Matt Berseth | March 25, 2008 06:53 AM
Compliments, great example.
About the Opacity, I'm using Vista, IE7, Silverlight 2.0.30226.2, clicking an Opacity setting doesn't change the opacity here.
Posted by: Hugo | April 1, 2008 02:07 AM
The opacity works great for me (Vista, IE8), and thanks for the live demo, Matt.
Posted by: Dave C | April 1, 2008 11:18 PM
Matt,
Have you found a way of sizing the width of the columns based on the page size? I have also noticed that I always get an extra column on the right hand side of the grid to fill the space – have you found a way of handling this?
Thanks
Richie
Posted by: Richie Scott | April 2, 2008 05:51 AM
Thank you Matt,
Very nice!
David
Posted by: David Roh | April 5, 2008 08:09 AM
Correction, not for any object, but for any arbitrary set of properties.
Thanks
Posted by: Sam Covington | April 6, 2008 08:11 PM
This is beautiful!
Thank you, Matt!
Posted by: Kevin Ortman | April 19, 2008 04:28 PM