示例#1
0
        void GenerateTemplate(ItemsControl control)
        {
            ItemsControlContentStrategy strategy = new ItemsControlContentStrategy();
            var templateContext = new TemplateContext
            {
                Element         = control,
                TemplateOptions = options
            };

            if (strategy.Applies(templateContext))
            {
                strategy.Apply(templateContext);
                control.ItemsSource = viewModel.People;
            }
        }
示例#2
0
 public void ApplyThrowsIfNotItemsSourceSubclass()
 {
     WrapInAThread(() =>
     {
         var textBox1 = new TextBox {
             DataContext = viewModel
         };
         Assert.Throws <ArgumentException>(() =>
         {
             var strategy1 = new ItemsControlContentStrategy();
             strategy1.Apply(new TemplateContext
             {
                 Element         = textBox1,
                 TemplateOptions = options
             });
         });
     });
 }