Exemple #1
0
        public static ControlTemplate ControlTemplate <TRootUI>(Type targetType, Action <Windows.DependencyObject> build) where TRootUI : Windows.DependencyObject, new()
        {
            //var root = new TRootUI();
            //build(root);
            //var ui = (Windows.Controls.ControlTemplate)CreateTemplate(nameof(Windows.Controls.ControlTemplate), root, targetType); // XamlWriter way, but does not support VisualStates
            var ui = (Windows.Controls.ControlTemplate)CreateTemplate(nameof(Windows.Controls.ControlTemplate), typeof(TRootUI), true, ConfigureRoot.CreateIdFor(build)); // Attached property way, invokes build for every template application

            return(CSharpMarkup.Wpf.ControlTemplate.StartChain(ui));
        }
        public static ItemsPanelTemplate ItemsPanelTemplate <TRootUI>(Action <Xaml.DependencyObject> build) where TRootUI : Xaml.UIElement, new()
        {
#if WINUI
            // Note that we cannot pass markup objects to the build action here, because we get the ui type instance.
            var ui = (Xaml.Controls.ItemsPanelTemplate)CreateTemplate(nameof(Xaml.Controls.ItemsPanelTemplate), typeof(TRootUI), true, ConfigureRoot.CreateIdFor(build));
#else
            var ui = new Xaml.Controls.ItemsPanelTemplate(() =>
            {
                var root = new TRootUI();
                build(root);
                return(root);
            });
#endif
            return(CSharpMarkup.WinUI.ItemsPanelTemplate.StartChain(ui));
        }
Exemple #3
0
        public static DataTemplate DataTemplate <TRootUI>(Action <Windows.DependencyObject> build) where TRootUI : Windows.DependencyObject, new()
        {
            // Note that we cannot pass markup objects to the build action here, because we get the ui type instance.
            var ui = (Windows.DataTemplate)CreateTemplate(nameof(Windows.DataTemplate), typeof(TRootUI), true, ConfigureRoot.CreateIdFor(build));

            return(CSharpMarkup.Wpf.DataTemplate.StartChain(ui));
        }
        public static ControlTemplate ControlTemplate(Type targetType, Action <Xaml.DependencyObject> build)
        {
            var ui = (Xaml.Controls.ControlTemplate)CreateControlTemplate(nameof(Xaml.Controls.ControlTemplate), typeof(Controls.Grid), true, ConfigureRoot.CreateIdFor(build), targetType);

            return(CSharpMarkup.WinUI.ControlTemplate.StartChain(ui));
        }