Setting BreadCrumb Items Programatically

2 posts, 1 answers
  1. Bartley
    Bartley avatar
    5 posts
    Member since:
    Oct 2013

    Posted 20 Feb 2015 Link to this post

    I am trying to set the Items of the BreadCrumb programmatically.  When One of the items changes I want the BreadCrumb to display the levels automatically, and not have to click on each item to set it.

    I am using the below as a sample snippet.

    Data = new ObservableCollection<RadBreadcrumbItem>();


                var brian = new RadBreadcrumbItem { Header = "Brian" };

                var bart = new RadBreadcrumbItem { Header = "Bart" };

                var ryan = new RadBreadcrumbItem { Header = "Ryan" };

                var jay = new RadBreadcrumbItem { Header = "Jay" };







                Root = new RadBreadcrumbItem {ItemsSource = Data};

    I want it to show by default as Brian/Ryan/Bart

    But like this I have to click each item in the BreadCrumb to set the item.

    How to do this programtatically?

  2. Answer
    Kiril Vandov
    Kiril Vandov avatar
    323 posts

    Posted 24 Feb 2015 Link to this post

    Hello Bartley,

    You can change the default displayed item of the RadBreadcrumb by binding to the CurrentItem property. For instance you can create a SelectedItem property in your view model and bind its value two way to the CurrenItem of the RadBreadcrumb. Then set in your ViewModel the value of the SelectedItem to be "bart"(the object) and the RadBreadcrumb will display the entire path leading to Bart. For a more complex data-binding scenarios and good practices you could read data-binding article of the RadBreadcrumb. Also you could check the features that support the RadBreadcrumb in this article.

    I hope this information helps.

    Kind regards,
    Kiril Vandov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft R3 2016 release webinar banner
Back to Top