PanelBar & Databinding

2 posts, 0 answers
  1. Mike
    Mike avatar
    1 posts
    Member since:
    Jan 2011

    Posted 25 Apr 2011 Link to this post


    Another databinding question for PanelBar... I have ViewModel with two properties Header (string) and View (UserControl)

    I want to bind "Header" property to the Header of RadPanelBarItem, and...
    "View" property on my VM to the "content" area of the RadPanelBarItem.

    For each ViewModel, there is only ONE Header and ONE View property.

    I see from examples something like


    But I can not get this working with databindings... there are HierarchicalDataTemplate examples, but that does not compute for me, mostly because HierarchicalDataTemplate ItemsSource="{Binding View}", since View in my case is a singel property, not collection; and I am not sure if HierarchicalDataTemplate would work for a (singel value) property as a source.

    This is what I got on my own...

    <telerik:RadPanelBar ItemsSource="{Binding ...}">
        <HierarchicalDataTemplate ItemsSource="{Binding View}">
         <TextBlock Text="{Binding Header}" />
           <ContentControl Content="{Binding View}" />
  2. Kiril Stanoev
    Kiril Stanoev avatar
    1508 posts

    Posted 27 Apr 2011 Link to this post

    Hi Mike,

    In your particular scenario, the View property must become a collection containing only one item.

    public class DataItem
        public DataItem()
            this.View = new ObservableCollection<ViewUserControl>();
        public string Header { get; set; }
        public ObservableCollection<ViewUserControl> View { get; set; }

    For further reference, please take a look at the attached project. Let me know if you have further questions or comments.

    Kind regards,
    Kiril Stanoev
    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
  3. DevCraft R3 2016 release webinar banner
Back to Top