static void OnPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs args)
        {
            var options = (TemplateOptions) args.NewValue;
            var element = source as UIElement;
            if (element == null)
            {
                throw new ArgumentException("DynamicTemplate attached property is only allowed to be used on UIElement subclasses");
            }

            var templateContext = new TemplateContext()
                            {
                                Element = element, TemplateOptions = options
                            };

            var strategy = StrategySelector.SelectStrategy(templateContext);
            if (strategy != null)
            {
                strategy.Apply(templateContext);
            }
        }
 public ContentStrategyBase SelectStrategy(TemplateContext context)
 {
     ScanForStrategies();
     return strategies.SingleOrDefault(s => s.Applies(context));
 }