-
Notifications
You must be signed in to change notification settings - Fork 10k
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
EventCallback not working as expected #8385
Comments
Event callback is working as long the component is not generic. The following examples are basically the same, the only difference is that one is normal component that have a defined value type and the other is generic. I don't know why it will not work because Usage
Generic ComponentThis implementation is NOT working!! NumericEdit.cshtml
BaseNumericEdit.cs
Ordinal ComponentThis implementation is working!! NumericEdit.cshtml
BaseNumericEdit.cs
|
This is also observed in the native InputNumber razor component. It only allows binding through the bind-Value method. |
I have the same issue with generic components and EventCallback. |
I tested this out, and it looks like we're not getting the right behavior. I'm not sure at this point if it's a codegen issue or if we're missing an overload.
|
This has VS tooling impact that we will need to coordinate with. |
Possibly related: #8336 |
Fixes: #8493 Fixes: #9632 Fixes: #9339 Fixes: #8385 Fixes: 10077 This fix adds support for type converters as well as a few other minor things we were missing from binding. The key thing about supporting conversions is that we new can support arbitrary types with `@bind`. This means you can use it with generics, which is something many users have tried. Along with type converters we get Guid and TimeSpan from the BCL. The BCL also includes converters for types we're less interested in like `short`.
Fixes: #8493 Fixes: #9632 Fixes: #9339 Fixes: #8385 Fixes: 10077 This fix adds support for type converters as well as a few other minor things we were missing from binding. The key thing about supporting conversions is that we new can support arbitrary types with `@bind`. This means you can use it with generics, which is something many users have tried. Along with type converters we get Guid and TimeSpan from the BCL. The BCL also includes converters for types we're less interested in like `short`.
* Add support for TypeConverter Fixes: #8493 Fixes: #9632 Fixes: #9339 Fixes: #8385 Fixes: 10077 This fix adds support for type converters as well as a few other minor things we were missing from binding. The key thing about supporting conversions is that we new can support arbitrary types with `@bind`. This means you can use it with generics, which is something many users have tried. Along with type converters we get Guid and TimeSpan from the BCL. The BCL also includes converters for types we're less interested in like `short`. * Use correct NumberStyles * Fix culture * Core check
This has been added in preview 7 - #10730 |
I have installed Preview 7 and I still get the error for generic EventCallback Error cannot convert from 'method group' to 'EventCallback' #10077 10077 |
@MichaelPeter I can also confirm that this bug is not fully fixed in preview 7. That is, it seems that it is working only if I specifically define generic type Not working:This will giving me error because TValue is not defined:
Working:This is working only after TValue is set. It is not recognized from the context.
|
Hi, it looks like you are posting on a closed issue/PR/commit! We're very likely to lose track of your bug/feedback/question unless you:
Thanks! |
May be related/duplicate of #12226 |
Describe the bug
I'm having trouble with the
EventCallback
in new RC. I have aSelectEdit
component withSelectedValue
andSelectedValueChanged
parameters. I want for my component to support two way binding (bind-SelectedValue
) and event handlers (SelectedValueChanged=@"OnValueChanged"
). This has worked withAction
, but now in the new RazorComponents when I convert to EventCallback I get the errors:SelectEdit.cshtml signature
Expected behavior
Users should be able to use both ways of handling the component values, and not just the bind- attributes. Custom actions should also be able to use if necessary.
or
Additional context
I have another component that is also using EventCallback but this one is not generic. On that components I can use events handler without any error. eg.
SimpleButton.cshtml
Usage
The text was updated successfully, but these errors were encountered: