Skip to main content

Microsoft Silverlight

Unanswered Question Formatting list as 3 column gridRSS Feed

(0)

kobruleht
kobruleht

Member

Member

162 points

584 Posts

Formatting list as 3 column grid

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.

fullsailrick
fullsail...

Contributor

Contributor

3699 points

829 Posts

Re: Formatting list as 3 column grid

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.

kobruleht
kobruleht

Member

Member

162 points

584 Posts

Re: Formatting list as 3 column grid

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.

Andrus.

 

jackbond
jackbond

Contributor

Contributor

2820 points

725 Posts

Re: Formatting list as 3 column grid

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.

kobruleht
kobruleht

Member

Member

162 points

584 Posts

Re: Formatting list as 3 column grid

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 ?

Andrus.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities