public static ControlTemplate ControlTemplate <TRootUI>(Type targetType, Func <UIElement> build) where TRootUI : Controls.Panel, new() { //var ui = (Windows.Controls.ControlTemplate)CreateTemplate(nameof(Windows.Controls.ControlTemplate), build().UI, targetType); // XamlWriter way, but does not support VisualStates var ui = (Windows.Controls.ControlTemplate)CreateTemplate(nameof(Windows.Controls.ControlTemplate), typeof(TRootUI), false, BuildChild.CreateIdFor(build)); // Attached property way, invokes build for every template application return(CSharpMarkup.Wpf.ControlTemplate.StartChain(ui)); }
public static ItemsPanelTemplate ItemsPanelTemplate <TRootUI>(Func <UIElement> build) where TRootUI : Xaml.Controls.Panel, new() { #if WINUI var ui = (Xaml.Controls.ItemsPanelTemplate)CreateTemplate(nameof(Xaml.Controls.ItemsPanelTemplate), typeof(TRootUI), false, BuildChild.CreateIdFor(build)); #else var ui = new Xaml.Controls.ItemsPanelTemplate(() => { var root = new TRootUI(); var child = build(); root.Children.Add(child.UI); return(root); }); #endif return(CSharpMarkup.WinUI.ItemsPanelTemplate.StartChain(ui)); }
public static DataTemplate DataTemplate <TRootUI>(Func <UIElement> build) where TRootUI : Controls.Panel, new() { var ui = (Windows.DataTemplate)CreateTemplate(nameof(Windows.DataTemplate), typeof(TRootUI), false, BuildChild.CreateIdFor(build)); return(CSharpMarkup.Wpf.DataTemplate.StartChain(ui)); }
public static ControlTemplate ControlTemplate(Type targetType, Func <UIElement> build) { var ui = (Xaml.Controls.ControlTemplate)CreateControlTemplate(nameof(Xaml.Controls.ControlTemplate), typeof(Controls.Grid), false, BuildChild.CreateIdFor(build), targetType); return(CSharpMarkup.WinUI.ControlTemplate.StartChain(ui)); }