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

Feature Request - Reusable razor component without polymorphism #24352

Closed
mrlife opened this issue Jul 28, 2020 · 4 comments
Closed

Feature Request - Reusable razor component without polymorphism #24352

mrlife opened this issue Jul 28, 2020 · 4 comments
Labels
area-blazor Includes: Blazor, Razor Components Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue.

Comments

@mrlife
Copy link
Contributor

mrlife commented Jul 28, 2020

What problem are you trying to solve?

Here is a simplified version of what I am trying to solve.

I am working on a razor component that uses a <select> to choose the value of a property on a tracked entity.

I have a base Dropdown class and multiple classes that derive from it, e.g. Color, which is a property on the tracked entity.

To make the razor component generic enough, I pass in a List<Dropdown> created from a List<Color>.

After the <select> is changed, I want to assign the new choice to the Color on the tracked entity.

There is no way I can find to set the Color property directly - razor component doesn't know it's a Color and no way to create a Color object using its type and the values from the List<Dropdown> corresponding to <select> value.

Without polymorphism support, is there a way it can be accomplished, or is it a current limitation?

Describe the solution you'd like

This is an idea:

// I'm using reflection in my code, but for this example, I'm leaving it out for simplicity
var createdColor = [create a new Color based on the chosen Dropdown and a passed in Type of Color];
trackedEntityColorProperty = createdColor;
@pranavkm pranavkm added the area-blazor Includes: Blazor, Razor Components label Jul 28, 2020
@mkArtakMSFT
Copy link
Member

Thanks for contacting us. This seems to be the same as #7268. Can you please confirm whether we got this right?

@mkArtakMSFT mkArtakMSFT added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Jul 28, 2020
@mrlife
Copy link
Contributor Author

mrlife commented Jul 28, 2020

@mkArtakMSFT This case is different - it doesn't have a child component or templated component. I basically hoped for a way to pass in a type, e.g. Color, and be able to create a new instance of that with an instance of the type it derives from, i.e. Dropdown. I think @typeparam may only for displaying content in a templated component.

I could be missing how #7268 could help, though.

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Jul 28, 2020
@mkArtakMSFT
Copy link
Member

Thanks for additional details. It's not still clear then what you're looking for.
Maybe you can share with us a small sample assuming the feature you're looking for is available and point us to the exact usage of it?

@mkArtakMSFT mkArtakMSFT added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Jul 29, 2020
@mrlife
Copy link
Contributor Author

mrlife commented Jul 29, 2020

@mkArtakMSFT Thanks for your consideration. I will go with another approach for this and close this out.

@mrlife mrlife closed this as completed Jul 29, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Aug 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue.
Projects
None yet
Development

No branches or pull requests

3 participants