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.

Add TemplatePartAttribute for Controls

See original GitHub issue

Is your feature request related to a problem? Please describe.

Named parts in control templates are not always clear to control authors, designers and other IDE tooling.

Describe the solution you’d like

WPF has the TemplatePart attribute used with templated controls. This indicates the named parts of the template, and their type, that are used within code-behind. This information was historically used in designers (Blend) as well as with automated checks to ensure default styles and their templates are complete.

This TemplatePart attribute should be added to avalonia and used for all controls (example from WPF). This should be used for all elements that start with the “PART_” prefix in the name.

[TemplatePart(Name="PART_ContentHost", Type=typeof(FrameworkElement))]
public abstract class TextBoxBase

Describe alternatives you’ve considered

The alternative is no attribute at all as currently exists.

Additional context

Information for PseuodClasses is provided in another attribute. This one should be included as well for completeness.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
maxkatz6commented, Mar 27, 2022

Created ticket in Rider’s YouTrack - https://youtrack.jetbrains.com/issue/RSRP-488276 Though I noticed they did not implemented support for the same attribute in WPF https://youtrack.jetbrains.com/issue/RSRP-330024 .

1reaction
maxkatz6commented, Jun 28, 2023

I wasn’t really thought about code generation, it sounds like a good argument to have this attribute even without support IDE support. Created issue for that https://github.com/AvaloniaUI/Avalonia/issues/11934 Though there is couple of problems what I see there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the TemplatePart attribute on a custom control?
I started developing a UWP XAML custom control using the new C++/WinRT language projection. I got the basic structure right, but I'm stuck...
Read more >
TemplatePartAttribute Class (System.Windows)
Represents an attribute that is applied to the class definition to identify the types of the named parts that are used for templating....
Read more >
PART Control Template and TemplatePartAttribute
The answer is TemplatePartAttribute. If we open the documentation of any control which has PART Control template then we can see that this ......
Read more >
Creating a Control That Has a Customizable Appearance
Learn about creating a control that has a customizable appearance, such as a checkbox with a custom control template.
Read more >
Tips on how to write well behaved WPF controls
It's going to be a fairly small article about several techniques that will help create well behaved Templatable and Stylable custom controls.
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