none
DataTemplateSelector issue

    Question

  • I'm trying to use a DataTemplateSelector so I can have two different types of content in the same list. I've got everything set up, but the below code won't compile. I get this error:

    Error 1 'MyNamespace.SlideItemDataTemplateSelector.SelectTemplate(object, Windows.UI.Xaml.DependencyObject)': cannot override inherited member 'Windows.UI.Xaml.Controls.DataTemplateSelector.SelectTemplate(object, Windows.UI.Xaml.DependencyObject)' because it is not marked virtual, abstract, or override

    public class SlideItemDataTemplateSelector : DataTemplateSelector
        {
            public DataTemplate ImageTemplate { get; set; }
            public DataTemplate VideoTemplate { get; set; }

            public override DataTemplate SelectTemplate(object item, DependencyObject container)
            {
                SlideItem slide = (SlideItem)item;

                if (slide.Type == SlideType.Video)
                    return this.VideoTemplate;

                return this.ImageTemplate;
            }
        }

    I'm at a loss. I've tried everything I can think off. The whole point of the DataTemplateSelector is to override the SelectTemplate method, but for some reason I'm not able to do that. Perhaps there's something simple I'm missing in my code?

    Saturday, March 03, 2012 4:39 AM

Answers

All replies