Exemplo n.º 1
0
        private void AddTrack(TracksMenu tracksMenu, int?trackId, string trackName, bool subTitle = false)
        {
            if (tracksMenu == null)
            {
                return;
            }

            var menuItem = new ToggleMenuFlyoutItem()
            {
                Text = trackName,
                Tag  = trackId
            };

            menuItem.Click += TrackMenuItem_Click;
            var menuItems = tracksMenu.MenuFlyout.Items;

            menuItems.Add(menuItem);

            if (menuItems.Count == 2)
            {
                var firstMenuItem = (menuItems.FirstOrDefault() as ToggleMenuFlyoutItem);
                if (subTitle || firstMenuItem?.Tag != null)
                {
                    firstMenuItem.IsChecked = true;
                }
                else
                {
                    menuItem.IsChecked = true;
                }
                VisualStateManager.GoToState(this, tracksMenu.AvailableStateName, true);
            }
        }
Exemplo n.º 2
0
 private void AddTracksMenu(string trackMenuName, TrackType trackType, string availableStateName, string unavailableStateName, bool addNoneItem = false)
 {
     if (GetTemplateChild(trackMenuName) is MenuFlyout menu)
     {
         var tracksMenu = new TracksMenu()
         {
             MenuFlyout           = menu,
             AvailableStateName   = availableStateName,
             UnavailableStateName = unavailableStateName,
             HasNoneItem          = addNoneItem
         };
         TracksMenus.Add(trackType, tracksMenu);
         if (addNoneItem)
         {
             AddNoneItem(tracksMenu);
         }
     }
 }
Exemplo n.º 3
0
        private void CheckMenuItem(TracksMenu tracksMenu, object menuItem)
        {
            ToggleMenuFlyoutItem toggleMenuFlyoutItem;
            bool isChecked;

            foreach (var item in tracksMenu.MenuFlyout.Items)
            {
                toggleMenuFlyoutItem = item as ToggleMenuFlyoutItem;
                if (toggleMenuFlyoutItem != null)
                {
                    isChecked = (item == menuItem);
                    if (toggleMenuFlyoutItem.IsChecked != isChecked)
                    {
                        toggleMenuFlyoutItem.IsChecked = isChecked;
                    }
                }
            }
        }
Exemplo n.º 4
0
 private void AddNoneItem(TracksMenu tracksMenu)
 {
     AddTrack(tracksMenu, null, ResourceLoader?.GetString("None"));
 }