Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are threre any plans to support Effects and Behavior ? #46

Closed
le-nn opened this issue Sep 21, 2022 · 8 comments
Closed

Are threre any plans to support Effects and Behavior ? #46

le-nn opened this issue Sep 21, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@le-nn
Copy link

le-nn commented Sep 21, 2022

Thank you for Amazing project !

Currently, we should access to Shadows, Behaviors, and Effects via @ref and Element.NativeControl.
Any plans to implement it as an Attribute on Blazor element?

@Dreamescaper
Copy link
Owner

Dreamescaper commented Sep 21, 2022

Thank you for Amazing project !

Thanks!
Shadows are relatively easy to add, I'll try to add them in the next couple of days.

As for behaviors and effects - could you describe your use cases? Which behaviors, for which controls?

I'm not sure how to support behaviors, as they are a bit foreign to Blazor. It would look nice to define them in markup, as you would do with XAML, but with Blazor that would require to create a separate Blazor component class for every possible behavior, and it doesn't seems like a great idea.

Is that ok simply to expose that as Behavior[] property? So that would look smth like that?

<Entry Behaviors="_entryBehaviors" />

@code {
    private Behavior[] _entryBehaviors = new[] { new MyFirstBehavior(), new MySecondBehavior() };
}

Alternative option I thought about is to create some generic component to hold behavior value, so it would look like this:

<Entry>
    <Behaviors>
        <BehaviorItem Type="MyFirstBehavior" />
        <BehaviorItem Type="MySecondBehavior" />
    </Behaviors>
</Entry>

WDYT?

@Dreamescaper
Copy link
Owner

As for Effects - all the above still applies, but additionally MAUI team doesn't recommend using them at all (they've only left them in MAUI to make transaction from XF easier), so I'm not sure if it makes sense to add the support for them at all here.

Again, please let me know your thoughts and use case.

@le-nn
Copy link
Author

le-nn commented Sep 21, 2022

Thanks for kind replying.

Here is my usecase.

case 1

I just wanted a declarative animation like the following library or react/flutter/swiftui.

https://github.com/jsuarezruiz/MauiAnimation

My team uses React a lot and recently started using Blazor, so I'm not familiar with Blazor or MAUI.
So sorry if I didn't come up with the best idea for Blazor and maybe asked a stupid question.

For HTML with CSS Transitions it's easy.
BlazorBindings needs to call methods like Element.NativeControl.ScaleTo(...).
I was looking for a way to make it easier, and I thought I would use Behavior

case 2

I tried to implement custom plat form effect such as the Windows mouse pointer, Context menus , but it will be resolved once the added features with NET7 RC1 are supported.

Thanks.

@Dreamescaper Dreamescaper mentioned this issue Sep 21, 2022
@Dreamescaper
Copy link
Owner

@le-nn
I've published a new release with Shadows support. You can read notes here.

@Dreamescaper
Copy link
Owner

As for behavior, I still don't really understand the use case :(

Could you give a XAML example how would you replace .ScaleTo() (invoked on some condition, I suppose) with a behavior?

@Dreamescaper Dreamescaper changed the title Are threre any plans to support Shadows, Effects and Behavior ? Are threre any plans to support Effects and Behavior ? Sep 27, 2022
@Dreamescaper Dreamescaper added the enhancement New feature or request label Sep 27, 2022
@Dreamescaper
Copy link
Owner

I have merged the support for Behaviors, it will be included in the next release, but you can try it with the nightly release.

While no built-in behaviors are provided, you can generate bindings for the third party behaviors via component generator.

You can take a look at the example here:
Elements.cs
CommunityToolkitBehaviors.razor

@Dreamescaper
Copy link
Owner

I am not sure whether it makes any sense to support Effects. While they are still supported for compatibility, MAUI guys do not recommend using them.

@Dreamescaper
Copy link
Owner

1.0 with Behaviors support is released to nuget, so I'm closing the issue.
Please log a separate issue if you need the support for Effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants