예제 #1
0
        public static void SaveCurrentState(AdvancedApplicationBar advancedApplicationBar)
        {
            var stateList = new List<BaseButton>();
            foreach (var buttonItem in advancedApplicationBar.ButtonItems)
            {
                if(buttonItem is AdvancedApplicationBarMenuItem)
                {
                    var aitem = buttonItem as AdvancedApplicationBarMenuItem;
                    var baseButton = new BaseMenuItemButton()
                    {
                        Text = aitem.Text,
                        IsVisible = aitem.Visibility == Visibility.Visible,
                        IsEnabled = aitem.IsEnabled,
                    };
                    stateList.Add(baseButton);
                }

                if(buttonItem is AdvancedApplicationBarIconButton)
                {
                    var aitem = buttonItem as AdvancedApplicationBarIconButton;
                    var baseButton = new BaseIconItemButton()
                    {
                        Text = aitem.Text,
                        IsVisible = aitem.Visibility == Visibility.Visible,
                        IsEnabled = aitem.IsEnabled,
                        IconUri=aitem.IconUri
                    };
                    stateList.Add(baseButton);
                }
            }
            PhoneApplicationService.Current.State[GetButtonKey()] = stateList;

            PhoneApplicationService.Current.State[GetAppBarKey()] =
                new ApplicationBarSaveStateItem().SaveState(advancedApplicationBar);
        }
        public static void SaveCurrentState(AdvancedApplicationBar advancedApplicationBar)
        {
            var stateList = new List <BaseButton>();

            foreach (var buttonItem in advancedApplicationBar.ButtonItems)
            {
                if (buttonItem is AdvancedApplicationBarMenuItem)
                {
                    var aitem      = buttonItem as AdvancedApplicationBarMenuItem;
                    var baseButton = new BaseMenuItemButton()
                    {
                        Text      = aitem.Text,
                        IsVisible = aitem.Visibility == Visibility.Visible,
                        IsEnabled = aitem.IsEnabled,
                    };
                    stateList.Add(baseButton);
                }

                if (buttonItem is AdvancedApplicationBarIconButton)
                {
                    var aitem      = buttonItem as AdvancedApplicationBarIconButton;
                    var baseButton = new BaseIconItemButton()
                    {
                        Text      = aitem.Text,
                        IsVisible = aitem.Visibility == Visibility.Visible,
                        IsEnabled = aitem.IsEnabled,
                        IconUri   = aitem.IconUri
                    };
                    stateList.Add(baseButton);
                }
            }
            PhoneApplicationService.Current.State[GetButtonKey()] = stateList;


            PhoneApplicationService.Current.State[GetAppBarKey()] =
                new ApplicationBarSaveStateItem().SaveState(advancedApplicationBar);
        }