protected virtual void OnDemoModulesChanged()
 {
     if (DemoModules != null && CurrentPivotItem != null)
     {
         CurrentPivotItem.ViewModel = DemoModules.ElementAt(DemoModuleIndex);
     }
 }
        private void OnPivotItemLoading(Pivot sender, PivotItemEventArgs args)
        {
            if (DemoModules == null)
            {
                return;
            }
            DemoModulePivotItem item = (DemoModulePivotItem)args.Item;

            if (!loadingByDemoModuleIndexChanged && CurrentPivotItem != null)
            {
                int oldIndex = CurrentPivotItem.Index;
                int newIndex = item.Index;
                int count    = DemoModules.Count();
                SetDemoModuleIndexSilently((DemoModuleIndex + count + ((newIndex - oldIndex + 2) % 3 == 0 ? 1 : -1)) % count);
            }
            loadingByDemoModuleIndexChanged = false;
            CurrentPivotItem = item;
            CurrentPivotItem.PreferedOptionsVisibility = PreferedOptionsVisibility;
            if (DemoModules != null)
            {
                item.ViewModel = DemoModules.ElementAt(DemoModuleIndex);
            }
        }