This is a migrated thread and some comments may be shown as answers.

Bind PanelBar to a complex class

2 Answers 30 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Guillaume
Top achievements
Rank 1
Guillaume asked on 13 Apr 2011, 09:42 AM
Hello,

I have created a class which is compilcated to bind to the PanelBar, so i need few advices from you.

Here is my class :
public class FlowTreeModel : INotifyPropertyChanged
   {
       public event PropertyChangedEventHandler PropertyChanged;
 
       private Organization _organization;
       private Dictionary<FolderType, DataItemTreeViewCollection> _items;
 
       public Organization Organization
       {
           get { return _organization; }
           set
           {
               _organization = value;
               OnPropertyChanged("Organization");
           }
       }
 
       public Dictionary<FolderType, DataItemTreeViewCollection> Items
       {
           get { return _items; }
           set
           {
               _items = value;
               OnPropertyChanged("Items");
           }
       }
 
       public FlowTreeModel()
       {
           Items = new Dictionary<FolderType, DataItemTreeViewCollection>();
       }
 
       /// <summary>
       /// Called when [property changed].
       /// </summary>
       /// <param name="propertyName">Name of the property.</param>
       public void OnPropertyChanged(string propertyName)
       {
           if (this.PropertyChanged != null)
           {
               PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
           }
       }
   }

In fact, I want each PanelBarItem has :
- the header binded on Organization property
- contains a TreeView where first parents nodes are each FolderType in Items property and childs of each parent node is the DataItemTreeViewCollection associate.

Ex :

- FolderType01
----DataItemTreeViewCollection01
- FolderType02
----DataItemTreeViewCollection02

I can set the header of each item by setting the ItemTemplate like this in RadPanelBar
ItemTemplate="{StaticResource HeaderDataTemplate}"
<DataTemplate x:Key="HeaderDataTemplate">
            <Grid>
                <TextBlock Text="{Binding Organization.Name}" Margin="5,5,0,5"/>
            </Grid>
        </DataTemplate>
But i can't set the content.

DataItemTreeViewCollection class is a recursive class who works fine with  HierarchicalDataTemplate Do you understand, what i want ? Best regards, Guillaume

2 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 18 Apr 2011, 04:06 PM
Hello Guillaume,

The RadPanelBar inherits from RadTreeView and the best way in these situation is to use nested telerik:HierarchicalDataTemplates and nested ViewModels bound to them. You may also need to expose some properties to use for Binding like Folders for example. The Folders should retrieves the collection of FoldertTypes from the Dictionary Like so:
private ObservableCollection<FolderType> folders;
       public ObservableCollection<FolderType> Folders
       {
           get
           {
               return folders;
           }
           set
           {
               this.folders = new ObservableCollection<FolderType>(Items.Keys);
               OnPropertyChanged("Folders");
           }
       }
For more info on how to use HierarchicaDataTemplates, pleasecheck out this article. Let us know if this helps you or not.

Kind regards,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Guillaume
Top achievements
Rank 1
answered on 28 Apr 2011, 10:50 AM
Hello,

Thanks for you advice. In fact, i have done with creating an ihnerit class of RadPanelBarItem and implementing my own UI logic (mix between bindings and controls manipulations).
The result is well.

Regards,
Guillaume
Tags
PanelBar
Asked by
Guillaume
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Guillaume
Top achievements
Rank 1
Share this question
or