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

Setting BreadCrumb Items Programatically

1 Answer 192 Views
BreadCrumb
This is a migrated thread and some comments may be shown as answers.
Bartley
Top achievements
Rank 1
Iron
Bartley asked on 20 Feb 2015, 04:05 PM
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" };

 

            ryan.Items.Add(bart);

            ryan.Items.Add(jay);

            brian.Items.Add(ryan);

 

            Data.Add(brian);

            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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Kiril Vandov
Telerik team
answered on 24 Feb 2015, 09:24 AM
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
Telerik
 

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.

 
Tags
BreadCrumb
Asked by
Bartley
Top achievements
Rank 1
Iron
Answers by
Kiril Vandov
Telerik team
Share this question
or