Esempio n. 1
0
        /// <summary>
        /// 将MenuModel转为MenuViewItem
        /// </summary>
        private void MenuitemToViewItem()
        {
            var m = new ObservableCollection <NavigationViewItemBase>();

            foreach (var item in _Menus)
            {
                switch (item.menuType)
                {
                case MenuType.Header:
                {
                    var header = new NavigationViewItemHeader()
                    {
                        Content    = item.title,
                        Tag        = item,
                        Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(Colors.Gray)
                    };
                    m.Add(header);
                }
                break;

                case MenuType.Menuitem:
                {
                    m.Add(new NavigationViewItem()
                        {
                            Name    = item.name,
                            Content = new Windows.UI.Xaml.Controls.TextBlock()
                            {
                                Text         = item.title,
                                TextTrimming = TextTrimming.WordEllipsis,
                                Margin       = new Thickness(0, 0, 8, 0)
                            },
                            Icon = new Windows.UI.Xaml.Controls.FontIcon()
                            {
                                FontFamily = (Windows.UI.Xaml.Media.FontFamily)Application.Current.Resources["FONTS_MaterialIcons"],
                                Glyph      = item.icon
                            },
                            Tag = item
                        });
                }
                break;

                case MenuType.Separator:
                {
                    m.Add(new NavigationViewItemSeparator());
                }
                break;

                default:
                    break;
                }
            }
            Menus = m;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Menus"));

            MenuUpdated?.Invoke(this, null);
        }
Esempio n. 2
0
 protected virtual void OnMenuOpdated(MenuUpdatedEventArgs e)
 {
     MenuUpdated?.Invoke(this, e);
 }
Esempio n. 3
0
 protected void OnMenuUpdate(FileMenuArgs args) => MenuUpdated?.Invoke(this, args);