question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: Add public APIs for creating FrameworkTemplate and derived types

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:39
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
baskrencommented, Nov 5, 2021

PLEASE add this feature ASAP.

7reactions
francoistanguaycommented, Aug 20, 2020

@jeromelaban Love the idea. FYI. Somewhat related to this - we wanted to simplify the story for virtualization in ItemsRepeater and introduced IElementFactory sometime back so that you are not required to provide a DataTemplate.

Would IElementFactory be used by ContentControl as well?

Otherwise pretty much back to square one,

Not being able to instantiate templates from C# is the main and almost only blocker to a C# first syntax.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Proposed API
Proposed APIs are a set of unstable APIs that are implemented in VS Code but not exposed to the public as stable APIs...
Read more >
Guide to building an enterprise API strategy
APIs enable enterprises to better deliver diverse data and services to internal and external customers, and open up new revenue streams.
Read more >
Entity framework attributes. In the Choose Model Contents step
Entity framework attributes. In the Choose Model Contents step, choose the Generate from a database option and click the Next button (see Figure...
Read more >
Public APIs Developers Can Use in Their Projects
Public APIs provide developers with access to existing functionality and data that they can use to create new applications.
Read more >
Generating REST APIs from data classes in Python
This solution uses data classes to generate Open API service definitions with AWS extensions and to create API Gateway configurations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found