[Proposal] Behaviors extension to VisualElementExtensions
See original GitHub issueBehaviors extension to VisualElementExtensions
- Proposed
- Prototype
- Implementation
- iOS Support
- Android Support
- macOS Support
- Windows Support
- Unit Tests
- Sample
- Documentation
Link to Discussion
Summary
I would like to propose that we add the WithBehavior(this VisualElement visualElement, Behavior behavior)
and WithBehaviors(this VisualElement visualElement, params Behavior[] behaviors)
extensions that will add the supplied behavior
to visualElement.Behaviors
.
Motivation
Reduces the amount of code developers need to write 😄
Detailed Design
public static class VisualElementExtensions
{
public static WithBehavior(this VisualElement visualElement, Behavior behavior)
{
visualElement.Behaviors.Add(behavior);
return visualElement;
}
public static WithBehaviors(this VisualElement visualElement, params Behavior[] behaviors)
{
foreach (var behavior in behaviors)
{
WithBehavior(behavior);
}
return visualElement;
}
}
Usage Syntax
Content = new Entry
{
Placeholder = "Start typing until MaxLength is reached...",
MaxLength = 100
}.WithBehavior(new MaxLengthReachedBehavior().Bind(
MaxLengthReachedBehavior.CommandProperty,
nameof(ViewModel.MaxLengthReachedCommand));
Drawbacks
n/a
Alternatives
n/a
Unresolved Questions
n/a
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Scripting API: PlayableExtensions
Extensions for all the types that implements IPlayable. Extension methods are static methods that can be called as if they were instance methods...
Read more ><behaviorExtensions> - .NET Framework
Behavior extensions enable the user to create user-defined behavior elements. These elements can be used alongside the standard Windows ...
Read more >How to make a clone/copy of a VisualElement?
This is how you make custom elements with custom behavior, like a TreeView. ... it looks like the first proposal would suit your...
Read more >Building Impactful Extension Programs By Understanding ...
This article describes an approach to understanding how Extension audiences move through the process of change as a means of delivering meaningful programming ......
Read more >Server behaviors, databases, and bindings in Dreamweaver
Learn more about the server behaviors extension, databases, and bindings in Adobe Dreamweaver.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey team & community,
@brminnick @jfversluis @VladislavAntonyuk @pictos
Would you mind voting on whether you would like to approve this PR or not. Given the RC is coming very soon it would be nice to get this in to help with the docs writing.
👍 for yes and 👎 for no
Oh yeah thanks! Closed now 😄