tags:

views:

36

answers:

0

Hi, I want to have WPF datagrid which is completely dynamic with columns as well as rows.

My table1,
  ID HotelName Type      Used   Date
   1  ABC         1       2     14/10
   2  DEF         2       5     15/10

Table 2(reference to column Type in table1),
  ID    Type   Rate 
  1     1 STAR  1000
  2     3 STAR  2500

I want to create XAML that displays the data in the following way(Example UI),

ABC
        1 STAR   
14/10   2 Used

DEF  
        3 STAR
15/10   5 Used  

Here, all the data is dynamic, there can be multiple dates for single hotel and multiple types as well. How will I display the data in the above manner.

foreach (DomainObject obj in result.ResultSet)
            {
                Type tp = (Type)obj;

                if (!Hotelnm.Contains(tp.HotelName))
                {
                    Hotelnm.Add(tp.HotelName);
                    Type.Add(new TypeViewModel(tp));
                }

            }

Hotelnm is a Hashset that contains unique hotel names and Type is the observable collection that has data from all the fields from both the tables.