protected override void InsertItem(int index, object item)
 {
     if (item is DataTemplate)
     {
         base.InsertItem(index, item);
     }
     else
     {
         GroupHeaderFooterItemTemplate vwc = item as GroupHeaderFooterItemTemplate;
         if (vwc != null)
         {
             if (vwc.Template == null)
             {
                 throw new ArgumentException("A VisibleWhenCollapsed object must have its Template property set to an instance of a DataTemplate.");
             }
             else
             {
                 base.InsertItem(index, item);
             }
         }
         else
         {
             throw new ArgumentException("Group headers and footers can only receive ClearHeadersFooters, DataTemplate, or VisibleWhenCollapsed objects.");
         }
     }
 }
Exemplo n.º 2
0
        static GroupConfiguration()
        {
            GroupConfiguration.HeadersProperty = GroupConfiguration.HeadersPropertyKey.DependencyProperty;
            GroupConfiguration.FootersProperty = GroupConfiguration.FootersPropertyKey.DependencyProperty;

            DefaultHeaderTemplate = new GroupHeaderFooterItemTemplate();
            DefaultHeaderTemplate.VisibleWhenCollapsed = true;
            DefaultHeaderTemplate.Template             = new DataTemplate();
            DefaultHeaderTemplate.Template.VisualTree  = new FrameworkElementFactory(typeof(GroupHeaderControl));
            DefaultHeaderTemplate.Template.Seal();
            DefaultHeaderTemplate.Seal();

            DefaultGroupConfiguration = new GroupConfiguration();
            DefaultGroupConfiguration.AddDefaultHeadersFooters();
            DefaultGroupConfiguration.Freeze();
        }