Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Formatting list as 3 column grid
4 replies. Latest Post by kobruleht on March 16, 2009.
(0)
kobruleht
Member
162 points
584 Posts
03-16-2009 3:09 PM |
Web service returns list of product names and prices:
Product1 $12
Product2 $23
Product3 $45
Product4 $56
etc.
I want to show this to shopping cart containing 3 columns where every cell contains single product like:
Name: product1 Name: product2 Name: product3
Price $12 Price: $23 Price: $ 45
Quantity to order: Quantity to order: Quantity to order:
Name: product4
Price: $56
Quantity to order:
How to convert data to such 3-column list ?
Should I create 3-column DataGrid or use WrapPanel ?
looked into [http://leeontech.wordpress.com/2008/12/20/sample-lob-app/] but it seems to complicated and I do'nt have sql server installed.
Andrus.
fullsail...
Contributor
3699 points
829 Posts
03-16-2009 3:29 PM |
Hi! Yeah, I would go ahead and make that a DataGrid. That way the person can have basic sorting based on price, or product name, etc. There is a good video about Binding to DataGrids in the Learn section of this site. I think by Todd Miranda.
03-16-2009 3:57 PM |
Using DataGrid:
- must create hard coded 3-column datagrid
- must create entity which has properties column1, column2, column3
- use manual for( var i=0; i<3; i++ ) loops to populate this entity 3 properties
This looks very ugly.
I'snt better solution to use wrappanel which wraps automatically after every 3 columns? If cart area is wider
then it can automatically accomodate more that 3 columns.
Have you looked into lee_sl link in my first message?. I don't understand how lee populates data to 3 columns.
jackbond
2820 points
725 Posts
03-16-2009 4:07 PM |
kobruleht:Should I create 3-column DataGrid or use WrapPanel ?
I don't think the current datagrid supports any sort of pivoting, so right now a WrapPanel is probably your best option. Unfortunately, this means you need to do a write a little more of the glue (i.e. can't simply databind a collection.) Hopefully a multi-column listbox will be revealed this week at Mix.
03-16-2009 4:37 PM |
I need also paging.
So best way is to use ListBox whose ItemTemplate is WrapPanel and implement next/prev page buttons.
Where to find sample control or code for this ?