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; } }
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 }); }); }); }