Breadcrumb connection to treeview

Navigation for WPF Forum

Posted 9 years ago by Arthur Damen
Version: 9.2.0515
Avatar
Hi,

I used your quick start breadcrumb to get started.
But now i want to connect a treeview to the breadcrumb.

In the Breadcrumb demo the data is retrieved from a xml file. In my case I want to use the local computer info to show up in the treeview.

Is there an easy way to connect the MyComputerData class used by the quick start breadcrumb???

Comments (3)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Arthur,

You would need to take the Styles for the various file system types (i.e. DirectoryData, DriveData, MyComputerData) and create copies that target TreeViewItem instead of BreadcrumbItem. TreeViewItem doesn't have an ImageSource property though, so there you'd need to:

1. Bind Header to the current DataContext (i.e. <Setter Property="Header" Value="{Binding}" />
2. Set HeaderTemplate to a DataTemplate that uses includes Image and TextBlock controls (with the appropriate bindings).

Finally, you'd have to duplicate the TreeView sync code from the Breadcrumb Demo. If you get stuck, please send over a small sample project that shows the issue to our support address. That will help us narrow down any issues.


Actipro Software Support

Posted 9 years ago by Arthur Damen
Avatar
it would have been nice if there was an example showing this.
I guess im not the only one searching for this.
Posted 9 years ago by Arthur Damen
Avatar
Ok, after adding the styles it worked.
I only had to adjust the mycomputerdata to an observablecollection for the treeview

  Dim MyFileInfo As MyComputerData

  MyFileInfo = New MyComputerData

  FileTreeView.ItemsSource = New ObservableCollection(Of MyComputerData)(New MyComputerData() {MyFileInfo})
and I adjusted the drivedata getdirectories property so that only when a drive is ready that it will be loaded. Otherwise this function will raise an event that the drive is not ready and i hate raised events when everything supposed to be ok....

            Dim DInfo As DriveInfo = Me.Info
            If DInfo.IsReady Then 'drive found?
              Dim directoryInfos() As DirectoryInfo = DInfo.RootDirectory.GetDirectories()
              For Each directoryInfo As DirectoryInfo In directoryInfos
                Me._directories.Add(New DirectoryData(directoryInfo))
              Next directoryInfo
            End If
The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.