Exemple #1
0
        private ItemGroup GetOrCreateGroup(object obj, int groupIndex)
        {
            ItemGroup group = null;

            var named = obj as IName;

            if (named != null || IsFlatList)
            {
                string name = named == null ? string.Empty : named.Name;
                if (IsFlatList)
                {
                    name = "flat";
                }
                _groups.TryGetValue(name, out group);

                // Update the underlying object anyway!
                //if (group != null)
                //{
                // TODO: Would have to replace the underlying one.   Not really a core scenario, having the header need to change. Footer yes though when I add that.
                //group.SetContent(obj, HeaderTemplate);
                //}
            }
//#if DEBUG
            else
            {
                throw new InvalidOperationException("The group objects must be an IName or a flat list.");
            }
//#endif

            if (group == null)
            {
//#if BUILDING_4TH_AND_MAYOR
                Panel panel = PanelType == "WrapPanel" ? (Panel)(new WrapPanel()) : (Panel)(new StackPanel());
//#else
                //Panel panel = (Panel)(new StackPanel());
//#endif
                string nametoUse = named == null ? string.Empty : named.Name;
                if (IsFlatList)
                {
                    nametoUse = "flat";
                }
                group = new ItemGroup(nametoUse, obj, IsFlatList ? null : HeaderTemplate, panel);
                // To preserve the Top template, insert + 1.
                group.InsertGroupIntoVisualTree(_stack, groupIndex + 1);


                _groups[nametoUse] = group;
                //_groupItems.Add(group);
            }
            //else
            //{
            //group.MoveGroupIfNeeded(_stack, groupIndex);
            //}

            return(group);
        }
        private ItemGroup GetOrCreateGroup(object obj, int groupIndex)
        {
            ItemGroup group = null;

            var named = obj as IName;
            if (named != null || IsFlatList)
            {
                string name = named == null ? string.Empty : named.Name;
                if (IsFlatList)
                    name = "flat";
                _groups.TryGetValue(name, out group);

                // Update the underlying object anyway!
                //if (group != null)
                //{
                // TODO: Would have to replace the underlying one.   Not really a core scenario, having the header need to change. Footer yes though when I add that.
                //group.SetContent(obj, HeaderTemplate);
                //}
            }
//#if DEBUG
            else
            {
                throw new InvalidOperationException("The group objects must be an IName or a flat list.");
            }
//#endif

            if (group == null)
            {
//#if BUILDING_4TH_AND_MAYOR
                Panel panel = PanelType == "WrapPanel" ? (Panel)(new WrapPanel()) : (Panel)(new StackPanel());
//#else
                //Panel panel = (Panel)(new StackPanel());
//#endif
                string nametoUse = named == null ? string.Empty : named.Name;
                if (IsFlatList)
                {
                    nametoUse = "flat";
                }
                group = new ItemGroup(nametoUse, obj, IsFlatList ? null : HeaderTemplate, panel);
                // To preserve the Top template, insert + 1.
                group.InsertGroupIntoVisualTree(_stack, groupIndex + 1);


                _groups[nametoUse] = group;
                //_groupItems.Add(group);
            }
            //else
            //{
                //group.MoveGroupIfNeeded(_stack, groupIndex);
            //}

            return group;
        }