///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        protected override IEnumerable GetDetailsForParentItem(DataGridCollectionViewBase parentCollectionView, object parentItem)
        {
            Debug.Assert(parentItem is SelectReportWrapper);

            IEnumerable subReports = null;
            if (null == parentItem)
                subReports = new List<SelectReportWrapper>();
            else
            {
                _report = parentItem as SelectReportWrapper;
                subReports = _report.SubReportWrappers;
            }

            return subReports;
        }
        /// <summary>
        /// Expands detail for selected report in report templates table.
        /// </summary>
        private void _ExpandDetail(SelectReportWrapper template)
        {
            Debug.Assert(null != template);

            try
            {
                _viewSourceTemplates.View.Refresh();
                // WORKAROUND: autkin : need call after source updating
                //                      without this code ExpandDetails do not work.
            }
            catch
            { }

            foreach (SelectReportWrapper wp in xceedGridTemplates.Items)
            {
                if (wp.Name.Name == template.Name.Name)
                {
                    if (0 < wp.SubReportWrappers.Count)
                        xceedGridTemplates.ExpandDetails(wp);
                    break; // operation done
                }
            }
        }
        /// <summary>
        /// Updates report template state.
        /// </summary>
        /// <param name="template">Current template.</param>
        /// <param name="wrapper">Subreport template.</param>
        private void _UpdateTemplateState(SelectReportWrapper template, SelectReportWrapper wrapper)
        {
            Debug.Assert(null != template);
            Debug.Assert(null != wrapper);

            //
            // WORKAROUND: autkin : CheckBox in xceedGreed work incorrect
            //

            // store check state
            bool isWrapperChecked = wrapper.IsChecked;

            // WORKAROUND - remove report in old state
            int index = _templates.IndexOf(template);
            _templates.RemoveAt(index);
            _viewSourceTemplates.View.Refresh();

            bool isChangedMasterReport = (0 < wrapper.SubReportWrappers.Count);
            if (isChangedMasterReport)
            {
                Debug.Assert(!isWrapperChecked);

                // when master report unselected - unselect all sub reports
                foreach (SelectReportWrapper subTemplate in template.SubReportWrappers)
                    subTemplate.IsChecked = false;

                template.IsChecked = isWrapperChecked; // restore real state
            }
            else
            {
                // if master report not selected - need select it
                if (!template.IsChecked && isWrapperChecked)
                    template.IsChecked = true;

                // restore sub report state
                foreach (SelectReportWrapper subTemplate in template.SubReportWrappers)
                {
                    if (subTemplate.Name.Name == wrapper.Name.Name)
                        subTemplate.IsChecked = isWrapperChecked;
                }
            }

            // update name (can changed by select\deselect sub reports)
            ReportInfo currentInfo = _GetReportInfoWithSelectedSubReports(template);
            ReportsGenerator generator = App.Current.ReportGenerator;
            template.Name = new SpecialName(template.Name.Name,
                                            generator.IsReportEnforceSplitted(currentInfo));

            // WORKAROUND - insert report in new state to last position.
            //              Only this case xceedGreed real updated view.
            _templates.Insert(index, template);

            // table source updated - need refresh
            _viewSourceTemplates.View.Refresh();
        }
        /// <summary>
        /// Updates master report GUI state.
        /// </summary>
        /// <param name="wrapper">Selected wrapper.</param>
        private void _UpdateMasterReportGui(SelectReportWrapper wrapper)
        {
            Debug.Assert(null != wrapper);

            foreach (SelectReportWrapper template in _templates)
            {
                if (template.Name.Name == wrapper.Name.Name)
                {
                    if (0 < wrapper.SubReportWrappers.Count)
                    {   // do only for master report with subreports
                        bool isChecked = template.IsChecked;
                        if (wrapper.IsChecked)
                            _ExpandDetail(wrapper);
                        else
                            _UpdateTemplateState(template, wrapper);
                        template.IsChecked = isChecked; // WORKAROUND: autkin:
                        // after calling _viewSourceTemplates.View.Refresh();
                        // CheckBox return to previosly state
                    }

                    break; // NOTE: report template wrapper updated
                }
            }
        }
        /// <summary>
        /// Gets report template info with selecetd sub reports.
        /// </summary>
        /// <param name="template">Seleceted template.</param>
        /// <returns>Report info with only selected sybreports.</returns>
        private ReportInfo _GetReportInfoWithSelectedSubReports(SelectReportWrapper template)
        {
            Debug.Assert(null != template);

            ReportsGenerator generator = App.Current.ReportGenerator;
            ReportInfo info = generator.GetReportInfo(template.Name.Name);

            var subReports = new List<SubReportInfo>();
            foreach (SubReportInfo subReport in info.SubReports)
            {
                bool isSelected = false;
                if (subReport.IsDefault)
                    isSelected = true; // NOTE: added as default
                else
                {   // check user's choice
                    foreach (SelectReportWrapper subTemplate in template.SubReportWrappers)
                    {
                        if (subTemplate.Name.Name == subReport.Name)
                        {
                            isSelected = subTemplate.IsChecked;
                            break; // NOTE: result founded
                        }
                    }
                }

                // add selected subreport
                if (isSelected)
                    subReports.Add(subReport);
            }

            _NormalizeSubReportGroup(subReports);

            return new ReportInfo(info.Name,
                                  info.Context,
                                  info.TemplatePath,
                                  info.Description,
                                  info.IsPredefined,
                                  subReports);
        }
        private int _GetSubReportsCount(SelectReportWrapper reportWrapper)
        {
            ReportsGenerator generator = App.Current.ReportGenerator;
            Debug.Assert(null != App.Current.ReportGenerator);
            Debug.Assert(generator.GetPresentedNames(false).Contains(reportWrapper.Name.Name));

            ReportInfo report = generator.GetReportInfo(reportWrapper.Name.Name);

            int result = 0;
            if ((null != report) && (null != report.SubReports))
                result = report.SubReports.Count;

            return result;
        }