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] Behaviors extension to VisualElementExtensions

See original GitHub issue

Behaviors extension to VisualElementExtensions

  • Proposed
  • Prototype
  • Implementation
    • iOS Support
    • Android Support
    • macOS Support
    • Windows Support
  • Unit Tests
  • Sample
  • Documentation

Link to Discussion

#28

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:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
bijingtoncommented, Mar 24, 2022

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

1reaction
bijingtoncommented, Mar 29, 2022

I think this is done with merging the Docs?

Oh yeah thanks! Closed now 😄

Read more comments on GitHub >

github_iconTop 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 >

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