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

How to use with Dynamic Content?

1 Answer 174 Views
BreadCrumb
This is a migrated thread and some comments may be shown as answers.
Noemata
Top achievements
Rank 1
Noemata asked on 12 May 2014, 02:15 PM
The samples provided with the BreadCrumb control suggest it can be used to coordinate navigation through a directory tree, but the provided samples all use static content to populate the BreadCrumb control's ItemSource data.

How can the BreadCrumb control be used with dynamic content?  For example, an XML representation that consists of an XPath that has a "Name" for a given "Folder" to represent a particular directory path where the path is built up dynamically as you navigate toward a particular target directory:

C:\Root\test1\test2\

[C:\] ^| [Root]^| [test1]^ | [test2]^

Where each breadcrumb shown above has it's data populated as you select the next, rather than having the entire path pre-built, as shown in the provided examples?

You would not know the target directory in advance of navigation if the Breadcrumb control were used in this manner, so the provided examples are not representative of actual usage for this scenario.

Sample XML:
<XmlDataProvider x:Key="FolderRoot">
<x:XData>
<Folder xmlns="" Name="C:\">
</Folder>
</x:XData>
</XmlDataProvider>

Note: the above XML is built dynamically as you navigate through directory structure.  This is just the very first node.

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 15 May 2014, 01:21 PM
Hello Mario,

The described requirement sounds like a load on demand functionality. I prepared a sample project which demonstrates load items on demand (dynamically) in the BreadCrumb. Basically you can generate the items in the children'ss collection in your view model. Here is an example in code for the collection property.
public ObservableCollection<ExplorerItem> Children
       {
           get
           {
               if (this.children == null || this.children.Count == 0)
               {
                   this.LoadChildren();
               }
 
               return this.children;
           }
       }
private void LoadChildren()
       {
           this.children.Add(new ExplorerItem() { Header = this.Header + "'s child", Path = this.Header + "'s child" });
       }
Please give this approach a try and let me know if I am missing something.

Regards,
Martin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
BreadCrumb
Asked by
Noemata
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or