using System;
using System.Windows;
using System35;
using JetBrains.Annotations;
namespace JetBrains.UI.Avalon
{
///
/// Supports a data template that executes some code to create the object graph.
///
public class DataTemplateDelegate : DataTemplate
{
#region Init
///
/// Creates a Data Template that produces the object graph at runtime.
///
/// The function to create the object graph.
public DataTemplateDelegate([NotNull] Func funcObjectGraphCreator)
{
if(funcObjectGraphCreator == null)
throw new ArgumentNullException("funcObjectGraphCreator");
var factory = new FrameworkElementFactory(typeof(TemplateBorder));
factory.SetValue(TemplateBorder.ObjectGraphCreatorProperty, funcObjectGraphCreator);
VisualTree = factory;
}
#endregion
}
}