/// <summary> /// Tack the changes in CurrentPath so we correctly can update the /// IsCurrentItem property on the child Items /// </summary> /// <param name="d"></param> /// <param name="e"></param> private static void CurrentDirectoryChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { BreadCrumb breadCrumb = d as BreadCrumb; if (e.NewValue != null) { BreadCrumbItem path = e.NewValue as BreadCrumbItem; foreach (object item in breadCrumb.Items) { (item as BreadCrumbItem).IsCurrentItem = false; } path.IsCurrentItem = true; if (breadCrumb.Items.Count > 0) { breadCrumb.IsAtHomeDirectory = (path == breadCrumb.Items[0]); } else { breadCrumb.IsAtHomeDirectory = true; } // Don't trigger directory changed event while closing if (!breadCrumb._isClosing) { breadCrumb.RaiseDirectoryChanged(path); } } }
/// <summary> /// Used for switching directories or for adding a new directory to the list of children /// </summary> /// <param name="path"></param> private void CloseToDirectory(BreadCrumbItem breadCrumbItem) { if (Items.Contains(breadCrumbItem)) { // This is what we aim for TargetDirectory = breadCrumbItem; CloseCurrentDirectory(); } }
public void CloseToDirectory(object directory) { BreadCrumbItem breadCrumbItem = null; if (crossRef.Keys.Contains(directory)) { breadCrumbItem = crossRef[directory]; } if (breadCrumbItem != null) { CloseToDirectory(breadCrumbItem); } }
/// <summary> /// Triggered when the close animation for a BreadCrumbItem is completed. /// The logic triggers the next animation in the chain until TargetPath is /// reached. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DirectoryCloseComplete(object sender, BreadCrumbEventArgs e) { e.BreadCrumbItem.Closed -= DirectoryCloseComplete; crossRef.Remove(e.BreadCrumbItem.Tag); Items.Remove(e.BreadCrumbItem); BreadCrumbItem nextInChain = Items[Items.Count - 1] as BreadCrumbItem; if (TargetDirectory == nextInChain) { _isClosing = false; } CurrentDirectory = nextInChain; CloseCurrentDirectory(); }
public void AddDirectory(string caption, object directory) { if (!crossRef.Keys.Contains(directory)) { BreadCrumbItem breadCrumbItem = new BreadCrumbItem() { Header = caption, Tag = directory }; breadCrumbItem.Clicked += new BreadCrumbEventHandler(BreadCrumbItemClicked); CurrentDirectory = breadCrumbItem; Items.Add(breadCrumbItem); crossRef.Add(directory, breadCrumbItem); } else { CloseToDirectory(directory); } }
private void RaiseDirectoryChanged(BreadCrumbItem breadCrumbItem) { BreadCrumbDirectoryEventArgs args = new BreadCrumbDirectoryEventArgs(DirectoryChangedEvent, breadCrumbItem.Tag); this.RaiseEvent(args); }
private void RaisePreviewDirectoryClosing(BreadCrumbItem breadCrumbItem) { BreadCrumbDirectoryEventArgs args = new BreadCrumbDirectoryEventArgs(PreviewDirectoryCloseToEvent, breadCrumbItem.Tag); this.RaiseEvent(args); }
public BreadCrumbEventArgs(RoutedEvent routedEvent, BreadCrumbItem path) : base(routedEvent) { this.BreadCrumbItem = path; }