Channel9Downloader.TemplateSelectors.CategoryHeaderTemplateSelector.SelectTemplate C# (CSharp) Method

SelectTemplate() public method

Selects the correct template for category selection group headers.
public SelectTemplate ( object item, DependencyObject container ) : System.Windows.DataTemplate
item object The item for which a template should be applied.
container System.Windows.DependencyObject The container of the item.
return System.Windows.DataTemplate
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var element = container as FrameworkElement;

            if (element != null && item != null && item is CollectionViewGroup)
            {
                var collectionViewGroup = item as CollectionViewGroup;

                if (collectionViewGroup.Name.Equals("Enabled"))
                {
                    return element.FindResource("EnabledGroupTemplate") as DataTemplate;
                }

                if (collectionViewGroup.Name.Equals("Disabled"))
                {
                    return element.FindResource("DisabledGroupTemplate") as DataTemplate;
                }

                return element.FindResource("AlphaticalGroupTemplate") as DataTemplate;
            }

            return null;
        }
CategoryHeaderTemplateSelector