I have a webmethod which returns the rows from the query, and passes it as a list. I am using two classes to assign the values.
| public class Types |
| { |
| public Types() |
| { |
| this.Defs = new List< Definitions>(); |
| } |
| public string Name |
| { |
| get; |
| set; |
| } |
| public int Sort |
| { |
| get; |
| set; |
| } |
| public Definitions Defs |
| { |
| get; |
| set; |
| } |
| } |
| public class Definitions |
| { |
| public string Name |
| { |
| get; |
| set; |
| } |
| } |
I am unsure if I am doing this correctly, but this is what I am trying to accomplish. Each Type is a RadPanelBarItem Parent of a Definition. There are multiple Types and Definitions. This is the closest I have come to implementing this in this way.
| ObservableCollection<Types> events = e.Result; |
| //find a specific object |
| String _type = events.FirstOrDefault().Type; |
| IEnumerable<Types> qry = from c in events |
| where (c.Type.ToString().Equals(_type)) |
| orderby c.Sort |
| select c; |
| int ct = 0; |
| if (qry != null) |
| { |
| RadPanelBarItem head = new RadPanelBarItem() |
| { |
| Header = _type |
| , |
| Style = Application.Current.Resources["radPanel_StyleInd"] as Style |
| }; |
| foreach (Types typ in qry) |
| { |
| if (inc.IsActive == true) |
| { |
| RadPanelBarItem pbi = new RadPanelBarItem() |
| { |
| Name = inc.IncType.ToLower() + "_Def_" + ct |
| , |
| Style = Application.Current.Resources["radPanel_StyleInd"] as Style |
| }; |
| pbi.Selected += new EventHandler<Telerik.Windows.RadRoutedEventArgs>(pbi_Selected); |
| head.Items.Add(pbi); |
| ct++; |
| } |
| }; |
| pb.Items.Add(head); |
| } |
| } |
Right away you can see that it isn’t dynamically adding the head—parent items. I need it to add the Types as the head, parent items and definitions as child items… any idea how to accomplish this?