Ejemplo n.º 1
0
        private static void NavigateCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            BreadcrumbButton _sender = (BreadcrumbButton)sender;

            _sender.RaiseNavigateEvent(_sender.Location);
        }
Ejemplo n.º 2
0
        private async void Breadcrumb_LayoutUpdated(object sender, EventArgs e)
        {
            if (InEditMode)
            {
                return;
            }

            if (!IsLoaded)
            {
                return;
            }

            double maxWidth       = ActualWidth - 50;
            double availableWidth = maxWidth;
            bool   hasHiddenItems = false;

            int count = Items.Count;

            List <string[]> hiddenItems = new List <string[]>();

            for (int i = count - 1; i >= 1; i--)
            {
                FrameworkElement item = (FrameworkElement)Items[i];

                if (availableWidth >= item.ActualWidth || i == count - 1)
                {
                    availableWidth -= item.ActualWidth;

                    item.MaxWidth = maxWidth >= 0 ? maxWidth : 0;

                    item.Visibility = Visibility.Visible;
                    Grid.SetColumn(item, GetBreadcrumbGridColumnOriginal(item));
                    Grid.SetColumnSpan(item, 1);
                }
                else
                {
                    availableWidth = -1;

                    item.Visibility = Visibility.Hidden;
                    Grid.SetColumn(item, 0);
                    Grid.SetColumnSpan(item, int.MaxValue);

                    BreadcrumbButton button = (BreadcrumbButton)item;
                    hiddenItems.Add(new string[] { button.Location, (string)button.Header });

                    hasHiddenItems = true;
                }
            }

            HasHiddenItems = hasHiddenItems;

            if (DropDownButton != null && !await IsEqual(_hiddenItems, hiddenItems))            // && PART_HiddenItemsHost != null)
            {
                _hiddenItems = hiddenItems;

                DropDownButton.Items.Clear();

                //PART_HiddenItemsHost.Children.Clear();

                foreach (string[] each in hiddenItems)
                {
                    BreadcrumbMenuItem menuItem = new BreadcrumbMenuItem();
                    menuItem.Location = each[0];
                    menuItem.Header   = each[1];

                    DropDownButton.Items.Add(menuItem);

                    //PART_HiddenItemsHost.Children.Add(menuItem);
                }
            }
        }