/// <summary>
        /// Create the template for the items in the history drop-down.
        /// </summary>
        private DataTemplate CreateComboBoxItemTemplate(PathConverter pathConverter)
        {
            DataTemplate            navComboBoxItemTemplate = new DataTemplate();
            FrameworkElementFactory comboBoxItemPanel       = new FrameworkElementFactory(typeof(StackPanel));
            FrameworkElementFactory comboBoxItemImage       = new FrameworkElementFactory(typeof(Image));
            FrameworkElementFactory comboBoxItemText        = new FrameworkElementFactory(typeof(TextBlock));

            comboBoxItemImage.SetValue(Image.WidthProperty, 16.0);
            comboBoxItemImage.SetValue(Image.HeightProperty, 16.0);
            comboBoxItemImage.SetBinding(Image.SourceProperty, new Binding("Entity.ImageSource"));
            comboBoxItemPanel.AppendChild(comboBoxItemImage);
            comboBoxItemText.SetBinding(TextBlock.TextProperty, new Binding()
            {
                Converter = pathConverter
            });
            comboBoxItemPanel.AppendChild(comboBoxItemText);
            comboBoxItemPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            navComboBoxItemTemplate.VisualTree = comboBoxItemPanel;

            return(navComboBoxItemTemplate);
        }
        /// <summary>
        /// Initializes an instance of the <c>FolderNavBar</c> class.
        /// </summary>
        public FolderNavBar()
        {
            PopupButton popupButton = new PopupButton()
            {
                DisplayMode = PopupButtonDisplayMode.ButtonOnly,
                IsRounded   = false,
                IsTransparencyModeEnabled = true
            };
            Image refresh = new Image()
            {
                Source            = new BitmapImage(new Uri("Resources/Refresh16.png", UriKind.Relative)),
                Stretch           = Stretch.None,
                VerticalAlignment = System.Windows.VerticalAlignment.Center
            };
            MultiBinding tooltip = new MultiBinding()
            {
                Converter = new StringFormatConverter(), ConverterParameter = "{}Refresh {0}"
            };
            PathConverter           pathConverter      = new PathConverter();
            FolderIconConverter     imageConverter     = new FolderIconConverter();
            FolderMenuIconConverter imageMenuConverter = new FolderMenuIconConverter();

            this.breadcrumb = new Breadcrumb();

            this.breadcrumb.Margin                = new Thickness(0);
            this.breadcrumb.MenuVerticalOffset    = -2;
            this.breadcrumb.AutoMinimizeItemCount = 0;
            this.breadcrumb.ConvertItem          += OnBreadcrumbConvertItem;
            this.breadcrumb.ImageMinWidth         = 16;

            this.breadcrumb.SetBinding(Breadcrumb.RootItemProperty, new Binding()
            {
                Source = this, Path = new PropertyPath("RootNode")
            });

            this.breadcrumb.ItemContainerStyle       = CreateRootBreadcrumbItemStyle(imageConverter);
            this.breadcrumb.ItemTemplate             = CreateBreadcrumbItemTemplate();
            this.breadcrumb.MenuItemTemplate         = CreateMenuItemNormalTemplate();
            this.breadcrumb.MenuItemContainerStyle   = CreateMenuItemContainerStyle(imageMenuConverter);
            this.breadcrumb.MenuItemExpandedTemplate = CreateMenuItemExpandedTemplate();
            this.breadcrumb.ComboBoxItemTemplate     = CreateComboBoxItemTemplate(pathConverter);

            this.breadcrumb.SetBinding(Control.BackgroundProperty, new Binding("Background")
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            this.breadcrumb.SetBinding(Control.BorderThicknessProperty, new Binding("BorderThickness")
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            this.breadcrumb.SetBinding(Control.BorderBrushProperty, new Binding("BorderBrush")
            {
                Source = this, Mode = BindingMode.TwoWay
            });

            tooltip.Bindings.Add(new Binding()
            {
                Source = this.breadcrumb,
                Path   = new PropertyPath("SelectedItem.Entity.Name"),
                Mode   = BindingMode.OneWay
            });
            popupButton.Content = refresh;
            this.breadcrumb.ActionButtons.Add(popupButton);

            this.Content = this.breadcrumb;

            this.history = new ObservableCollection <FolderNavNode>();
            this.breadcrumb.ComboBoxItemsSource  = history;
            this.breadcrumb.SelectedItemChanged += OnSelectedItemChanged;

            this.SetBinding(FolderNavBar.IsEditingProperty, new Binding("IsEditing")
            {
                Source = this.breadcrumb
            });

            if (pathConverter != null)
            {
                pathConverter.SetBinding(PathConverter.RootProperty, new Binding("RootNode")
                {
                    Source = this, Mode = BindingMode.OneWay
                });
            }
        }