using C1.Xaml;
using System;
using System.Reflection;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace ControlExplorer
{
    public class SampleViewModel
    {
        private UserControl _demo;
        public string Title { get; set; }
        public string Description { get; set; }
        public string SampleIconKey { get; set; }
        public Func<UserControl> CreateDemo { get; set; }
        public ControlViewModel Control { get; set; }

        public UserControl Demo
        {
            get
            {
                if (_demo == null)
                    _demo = CreateDemo();
                return _demo;
            }
        }

        public DataTemplate SampleIcon
        {
            get
            {
                if (App.Current.Resources.ContainsKey(SampleIconKey))
                    return App.Current.Resources[SampleIconKey] as DataTemplate;
                else
                    return Control.IconTemplate;
            }
        }
    }
}
