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

How to get ChildContent to work in Blazor?? #74

Open
mddifilippo89 opened this issue Aug 4, 2023 · 8 comments
Open

How to get ChildContent to work in Blazor?? #74

mddifilippo89 opened this issue Aug 4, 2023 · 8 comments
Assignees
Labels
bug Something isn't working status: in-review

Comments

@mddifilippo89
Copy link

private RenderFragment childContent { get; set; }

private RenderFragment AddContent() => builder =>
{
    builder.AddContent(1, textContent);

};

updating-panes.zip

@mddifilippo89
Copy link
Author

mddifilippo89 commented Aug 7, 2023

@igdmdimitrov @ig-robstoffers

In blazor a customer is trying to do the following: (If there is a solution already available please assist).

I want to change the child of a docking element during the execution.

Example:

IgbContentPane contentPane1 = new IgbContentPane { PaneType = DockManagerPaneType.ContentPane, Size = 600, Header = "Workspace", ContentId = "content1", IsPinned = true, ChildContent = ??????????????????????? };

I need an option to add content on the fly.
For example, I have a list of UI component names on the left side.
The user should be able to drag those to the right and place them on the main panel.
The number of controls in the docking panel is flexible. I cannot know in advance how many slots there will be.
This is the reason I want to set those in the code section.
Would you happen to have a solution for this case?

image

@igdmdimitrov
Copy link
Contributor

@mddifilippo89 , in Web Components you can modify the layout object of the Dock Manager and then update like this - Update Layout. I'm not sure how this can be done in Blazor, so maybe @gmurray81 can answer this.

@mddifilippo89
Copy link
Author

@gmurray81
Updating the layout is not documented in Blazor as suggested in WebComponents.

@gmurray81
Copy link
Member

It would be more usual to make the pabe children conditional in the razor like you would do with Angular.

But if doing it this way. The easiest method it jus to interleave markup when specifying the child content like ChildContent =@(

...
)

Something along those lines. The sort of thing you'd do in react. Like I explained when this question came up in scrum.

@gmurray81
Copy link
Member

GitHub mangled that a bit...

ChildContent = @(<div>...</div>)

@gmurray81
Copy link
Member

You can also specify a render fragment as a function, you you kind of need to know what you are doing. I'm not sure if MS has some good doc on it

@gmurray81
Copy link
Member

Ah in the above. I think you still want it to be a function that takes the context and returns the markup so that it has the data context. IIRC an arrow function will do. If you Google it, you should see, if not I can find an example somewhere. This isn't anything custom from us. It's standard Blazor stuff.

@gmurray81
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status: in-review
Projects
None yet
Development

No branches or pull requests

3 participants