Skip to content

Proposal: Add public APIs for creating FrameworkTemplate and derived types #2898

@jeromelaban

Description

@jeromelaban

Proposal: Add public APIs for FrameworkTemplate and derived types

Some scenarios for libraries are complexified when trying to create FrameworkTemplate and derived types, having to use XamlReader to create them.

Summary

Add the ability to create DataTemplate, ControlTemplate, and ItemsPanelTemplate types from code:

var dataTemplate = new DataTemplate(() => new TextBlock() { Text = "My text" });
var itemsPanelTemplate = new ItemsPanelTemplate(() => new StackPanel());
var controlTemplate = new ControlTemplate(typeof(ContentControl), () => new ContentPresenter());

Rationale

This will simplify the creation of Framework Templates and potentially improve performance by remove the parsing of literal XAML.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions