/// <summary>
        /// Restores the state of the tab set.
        /// </summary>
        /// <typeparam name="TTabModel">The type of tab model</typeparam>
        /// <typeparam name="TTabViewModel">The type of tab view model to be displayed in the app.</typeparam>
        /// <param name="tabablzControl">The control in which to restore the items</param>
        /// <param name="tabSetState">The state of the tab set to be restored</param>
        /// <param name="viewModelFactory">The function that creates the view model based on a model</param>
        public static void RestoreTabSetState <TTabModel, TTabViewModel> (TabablzControl tabablzControl, TabSetState <TTabModel> tabSetState, Func <TTabModel, TTabViewModel> viewModelFactory)
        {
            var restoreSelectedTabItem = (Action)(() => tabablzControl.SelectedIndex = tabSetState.SelectedTabItemIndex ?? -1);

            foreach (var tabModel in tabSetState.TabItems)
            {
                var tabViewModel = viewModelFactory(tabModel);
                if (tabViewModel != null)
                {
                    tabablzControl.AddToSource(tabViewModel);
                }
            }

            tabablzControl.Dispatcher.BeginInvoke(restoreSelectedTabItem, DispatcherPriority.Loaded);
        }
Exemple #2
0
        /// <summary>
        /// Restores the state of the tabSet
        /// </summary>
        /// <typeparam name="TTabModel">The type of tab model</typeparam>
        /// <typeparam name="TTabViewModel">The type of tab view model to be displayed in the app.</typeparam>
        /// <param name="tabablzControl">The control in which to restore the items</param>
        /// <param name="tabSetState">The state of the tab set to be restored</param>
        /// <param name="viewModelFactory">The function that creates the view model based on a model</param>
        public static void RestoreTabSetState <TTabModel, TTabViewModel>(TabablzControl tabablzControl, TabSetState <TTabModel> tabSetState, Func <TTabModel, TTabViewModel> viewModelFactory)
        {
            foreach (var tabModel in tabSetState.TabItems)
            {
                tabablzControl.AddToSource(viewModelFactory(tabModel));
            }

            tabablzControl.Dispatcher.BeginInvoke(new Action(() =>
            {
                tabablzControl.SelectedIndex = tabSetState.SelectedTabItemIndex ?? -1;
            }), DispatcherPriority.Loaded);
        }