Пример #1
0
        /// <summary>
        /// Create the style for the navigation menu items.
        /// </summary>
        private Style CreateMenuItemContainerStyle(FolderMenuIconConverter imageMenuConverter)
        {
            Style menuItemContainerStyle = new Style()
            {
                TargetType = typeof(MenuItem)
            };
            Setter icon = new Setter()
            {
                Property = MenuItem.IconProperty,
                Value    = new Binding("Entity.ImageSource")
                {
                    Converter = imageMenuConverter
                }
            };

            menuItemContainerStyle.Setters.Add(icon);

            return(menuItemContainerStyle);
        }
Пример #2
0
        /// <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
                });
            }
        }